如何仅通过文件模式更改来大规模解决 Git 冲突?
我正在尝试合并两个存储库,并且只有几个“真正的”冲突,但“两者都添加”大约有 70 个文件冲突。然而,当查看 git diff 时,它只显示文件模式已更改。
批量接受当前文件模式并忽略传入文件模式的最佳方法是什么?
一点背景: 这两个存储库具有相同的代码,但其中一个已通过 SVN 进行跟踪,因此没有历史记录。我现在使用 git-svn 来跟踪它并将其与当前的 git 存储库合并。
合并时传入的冲突显示为: 冲突(添加/添加):framework/file/name.php 中的合并冲突 自动合并失败;修复冲突,然后提交结果。
Git 状态显示: 两者都添加:framework/file/name.php
如果我使用 git mergetool,它不会显示任何冲突。使用此方法检查每个文件需要很长时间。
I am trying to merge two repositories, and there are only a couple of "real" conflicts, but there are about 70 file conflicts of "Both added". When viewing a git diff, however, it only shows file mode changed.
What would be the best way to mass-accept the current file mode and ignore the incoming file mode?
A little background:
These 2 repositories are of the same code, but one has been tracked through SVN, so doesn't have a history. I'm using git-svn to track it now and merge it with the current git repository.
The incoming conflicts on merge appear as:
CONFLICT (add/add): Merge conflict in framework/file/name.php
Automatic merge failed; fix conflicts and then commit the result.
Git status shows:
both added: framework/file/name.php
If I use the git mergetool, it does not show any conflicts. Going through each file using this method takes a very long time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,在尝试了所有各种合并策略,并确定我需要从存储库中获取文件模式,放弃本地文件模式之后,我想到的最佳解决方案是使用:
git checkout --theirs <远程/分支> -- 文件模式更改的路径,并使用
git mergetool
解决代码冲突。使用 git diff,我可以看到哪些文件是文件模式更改,哪些是文件代码更改。
git merge
使用--recursive -Xours
作为默认合并策略。有一个 git 配置变量:core.fileMode 可以忽略文件模式更改。
请参阅:如何让 Git 忽略文件模式 (chmod) 更改?
So after trying all the various merge strategies, and determining that I needed to take the file mode from the repository, discarding the local file mode, the best solution I came up was to use:
git checkout --theirs <remote/branch> -- path
for the filemode changes, and usedgit mergetool
for the code conflict resolution.Using git diff, I could see which files were filemode changes, and which were file code changes.
git merge
uses--recursive -Xours
as the default merge strategy.There is a git config variable: core.fileMode that can ignore file mode changes.
See: How do I make Git ignore file mode (chmod) changes?
git merge -XoursbranchToMergeIn 怎么样?它将合并两者并优先考虑您当前的分支。从未尝试过改变模式,但应该可以解决这个问题...
使用 jeffromi 的合并策略进行编辑。
How about
git merge -Xours branchToMergeIn
? It will merge the two and give preference to your current branch. Never tried it with mode changes, but should do the trick...edited with jeffromi's merge strategy.