Git merge - 手动合并 - 强制冲突具有完整的新旧文件版本
如何强制 git merge 在所有文件或所有不同的文件上生成冲突,以生成具有整个旧版本和整个新版本的冲突,此类文件的示例:我
<<<<<<<<<<A
A
B
C
D
OLD
OLD
OLD
E
F
G
...
Z
============
A
B
C
D
NEW
NEW
NEW
EEEEEEE
FFFFF
GGG
...
Z
>>>>>>>>>>B
的想法是我想手动合并两个文件的全部内容,不如果行相同或者一个分支继承自整个前一个分支,例如:
$ echo ABC > file
$ git add file
$ git commit -m '+) file = ABC'
[master 6e91bce] +) file += ABC
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file
$ git checkout -b new_branch
Switched to a new branch 'new_branch'
$ echo DEF >> file
$ git add file
$ git commit -m '+) file += DEF'
[new_branch 27e29bf] +) file += DEF
1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff new_branch
Automatic merge went well
$ cat file
ABC
DEF
我理解 git
自动将“DEF”添加到“文件”的原因。但我想要一种强制 git“思考”的方法:
- master/file 和 new_branch/file 不同
- 我会与整个旧版本和整个新版本发生冲突,让我的用户手动解决它
我已经阅读了其他关于制作的帖子“合并驱动程序”,但我还不清楚如何使用它来制作 git。 (脚本很明显,只有几行)。
PS 对于感兴趣的人:我不使用任何合并工具。我想将 TSV 电子表格与数据集和结果集合并。在所有情况下,当它们不同时(即使仅在一个分支上编辑),我想使用我自己的工具链来手动处理它们来处理这些数据集。
How to force git merge to generate conflict on all file or all file that differ to generate conflict having whole old and whole new version, example of such file :
<<<<<<<<<<A
A
B
C
D
OLD
OLD
OLD
E
F
G
...
Z
============
A
B
C
D
NEW
NEW
NEW
EEEEEEE
FFFFF
GGG
...
Z
>>>>>>>>>>B
The idea is that I would like to merge manually having whole contents of two files, no metter if lines are identical or one branch is inheriting from whole previous, example:
$ echo ABC > file
$ git add file
$ git commit -m '+) file = ABC'
[master 6e91bce] +) file += ABC
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file
$ git checkout -b new_branch
Switched to a new branch 'new_branch'
$ echo DEF >> file
$ git add file
$ git commit -m '+) file += DEF'
[new_branch 27e29bf] +) file += DEF
1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff new_branch
Automatic merge went well
$ cat file
ABC
DEF
I understand the reason why git
automatically addded "DEF" to "file". But I would like a way to force git "to think" :
- master/file and new_branch/file differs
- I will make a conflict with whole OLD and whole NEW version to let my users to manually resolve it
I've read other posts about making "merge driver", but it's far from clear to me how to make git using it. (Script is obvious, just a few lines).
P.S. For interested people: I do not use any merge tool. I'd like to merge TSV spreadsheets with DataSets and ResultsSets. In all cases when they differ (even if it's edit only on one branch), I'd like to process them manually with my own toolchain for processing those DataSets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你仍然需要告诉 Git 这些应该被视为二进制文件,如果有任何差异就会导致冲突。现在由您自己使用 git show otherbranch:thefile 和 git show HEAD:thefile 等命令来调查这些文件。编辑文件后,添加它并
git commit
。You still need to tell Git that these should be treated as binary files which will result in a conflict if there is any difference. It's up to you now to investigate the files yourself with something like
git show otherbranch:thefile
andgit show HEAD:thefile
. Once you edit the file, you add it andgit commit
.