Git合并 - 手动合并 - 强制冲突具有整个旧的和新的文件版本 [英] Git merge - manual merge - forcing conflic having WHOLE old and new file version

查看:563
本文介绍了Git合并 - 手动合并 - 强制冲突具有整个旧的和新的文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



<$ p

$ p $ <<<<<<<<<<<<<<<<<<<<<$$$$$$$$$$$$$B
C
D
OLD
OLD
OLD
E
F
G
...
Z
==== ========
A
B
C
D



EEEEEEE
FFFFF
GGG
...
Z

>>>>>>>>>>> B

这个想法是我想手动合并两个文件的全部内容,如果行是例如:

  $ echo ABC>文件
$ git添加文件
$ git commit -m'+)file = ABC'
[master 6e91bce] +)file + = ABC
1个文件已更改,1个插入+),0删除( - )
创建模式100644文件
$ git checkout -b new_branch
切换到新分支'new_branch'
$ echo DEF>>文件
$ git添加文件
$ git commit -m'+)file + = DEF'
[new_branch 27e29bf] +)file + = DEF
1个文件已更改,1个插入(+),0删除( - )
$ git checkout master
转换到分支'master'
$ git merge --no-ff new_branch
自动合并顺利进行
$ cat file
ABC
DEF

我了解 git 自动将DEF添加到文件中。但我想要一种强制git思考的方式:


  • master / file和new_branch / file不同
  • 我会与整个OLD和整个NEW版本发生冲突,让我的用户手动解决它。



已经阅读了其他关于制作合并驱动程序的文章,但是如何使用它来制作git还不是很清楚。 (脚本很明显,只有几行)。



对于感兴趣的人:我不使用任何合并工具。我想要将 TSV电子表格与DataSets和ResultsSets合并。在所有情况下,即使它们只在一个分支上编辑(即使它只在一个分支上编辑),我也想用我自己的工具链手动处理它们以处理这些数据集。

解决方案

您仍然需要告诉Git这些应该被视为二进制文件,如果有任何区别,将导致冲突。你现在可以自己调查一下这些文件,例如 git show otherbranch:thefile git show HEAD:thefile 。一旦你编辑了这个文件,你可以添加它并 git commit


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.

解决方案

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.

这篇关于Git合并 - 手动合并 - 强制冲突具有整个旧的和新的文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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