如何在 git 功能分支工作流中处理 xml/html? [英] How to handle xml/html in git feature branch workflow?

查看:28
本文介绍了如何在 git 功能分支工作流中处理 xml/html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目在相当近的代码方面工作(在代码的一个相当小的地理区域内并行发生很多变化),我们基于功能分支的 git 工作流程对我们的 Java 代码非常有效.

Our project is working within fairly close quarters code-wise (a lot of changes happening in parallel in a fairly small geographical area of the code), and our feature branch based git workflow works out really nice for our java code.

但是 xml/html 的东西并不能很好地工作.简单的不相关更改(设计师添加周围的 div,开发人员更改其中元素的 id)会产生真正灾难性的合并.

But the xml/html stuff is not working really well. Simple unrelated changes (a designer adding a surrounding div, a developer changing an id of an element within) gives really disasterous merges.

我意识到可能有几种处理方法.一个好的 git xml 合并将是最佳的,或者对另一个 xml/html 代码的重新格式化设置限制.不在如此近的地方工作将是另一种(不可接受的)选择.

I realize there may be several options on how to handle this. A good git xml merge would be optimal, or putting restrictions on reformatting of xml/html code another. Not working in such close quarters would be another (unacceptable) option.

你如何有效地解决这个问题?

How do you solve this problem efficiently ?

推荐答案

Git 允许 自定义合并驱动程序,通过 gitattributes 每个路径(例如对于所有 *.xml 文件).

Git allows for custom merge drivers, selected via gitattributes per path (e.g. for all *.xml files).

您需要找到一个支持 XML 的合并驱动程序,此外还可能编写一个简单的脚本来在 Git 约定和上述合并驱动程序约定之间进行转换.例如,有 XML::Merge Perl 模块.有 XyDiff,但它看起来缺少三向合并(我猜测对于 XML 构建 3 路合并,如 A Formal 中所述对 Diff3 论文 (PDF) 的调查不起作用).您还可以阅读匹配、比较和合并 XML 博文(或其中引用的文章).

What you need to find is a XML-aware merge driver, plus possibly also write a simple script to transform between Git conventions and said merge driver conventions. There is for example XML::Merge Perl module. There is XyDiff, but it looks like it lacks three-way merge (and I guess that for XML building 3-way merge from diffs like described in A Formal Investigation of Diff3 paper (PDF) wouldn't work). You can also read Matching, diffing and merging XML blog post (or article referenced therein).

另一种解决方案是为 XML 文件取消设置合并属性(它们将被视为二进制文件.合并冲突),并使用一些图形合并工具来解决合并冲突,也许通过 git 合并工具.

Another solution would be to unset merge attribute for XML files (they would be treated like binary files wrt. merge conflicts), and use some graphical merge tool to resolve merge conflicts, perhaps via git mergetool.

这篇关于如何在 git 功能分支工作流中处理 xml/html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆