Git merge - manual merge - forcing conflic having WHOLE old and new file version

拜拜、爱过 提交于 2019-12-12 04:03:28

问题


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.


回答1:


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 and git show HEAD:thefile. Once you edit the file, you add it and git commit.



来源:https://stackoverflow.com/questions/8969295/git-merge-manual-merge-forcing-conflic-having-whole-old-and-new-file-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!