我是否必须提交合并以使git-rerere记录我的冲突解决方案?

时间:2012-04-02 07:41:00

标签: git merge-conflict-resolution git-rerere

我正在使用git-rerere用于其预期目的,在这些分支开发时逐步记录两个分支(主分支和主题分支)之间的冲突解决方案,而不会创建不必要的合并提交。然而,即使在阅读了git-rerere manpage后,我还不清楚rerere何时实际记录了我的冲突解决方案。我检测和解决新合并冲突的标准工作流是从主题分支执行git merge master,解决冲突,然后暂存所有文件并使用git commit -m "Finished test merge"提交合并,然后使用{撤消合并{1}},仅留下git reset --hard HEAD^存储的录制分辨率。

然而,这似乎有点傻。创建一个提交,然后撤消它只是为了记录分辨率?在阅读git-rerere的联机帮助页后,我仍然不清楚它何时记录我的决议。仅仅暂存冲突的文件是否足够,或者我是否真的需要在解决冲突之后创建合并提交,就像我一直在做的那样?

2 个答案:

答案 0 :(得分:12)

从联系手册:

Running the git rerere command immediately after a conflicted automerge
records the conflicted working tree files, with the usual conflict
markers <<<<<<<, =======, and >>>>>>> in them. Later, after you are
done resolving the conflicts, running git rerere again will record the
resolved state of these files.

As a convenience measure, git merge automatically invokes git rerere
upon exiting with a failed automerge and git rerere records the hand
resolve when it is a new conflict, or reuses the earlier hand resolve
when it is not. git commit also invokes git rerere when committing a
merge result. What this means is that you do not have to do anything
special yourself (besides enabling the rerere.enabled config variable).

因此您不必提交和撤消提交。您可以在没有参数的情况下运行git rerere来记录提交。

答案 1 :(得分:0)

  

仅暂存有冲突的文件就足够了

您必须确保解决冲突而不会留下冲突标记。

请参见commit f427869commit bc4caecThomas Gummerer (tgummerer)(2018年8月28日)。
建议者:Junio C Hamano (gitster)
(由Junio C Hamano -- gitster --commit d88949d中合并,2018年9月17日)

请参见commit b9b07efThomas Gummerer (tgummerer)(2018年8月28日)。
帮助者:Junio C Hamano (gitster)
(由Junio C Hamano -- gitster --commit 4dd0c4a中合并,2018年9月17日)

  

.gitattributes:为相关文件添加冲突标记大小

     

git.git中的某些文件包含行,这些示例在示例或测试中或在Documentation/gitk.txt中由于asciidoc标题而看起来像冲突标记。

     

具有与实际内容相同长度的冲突标记可能会使人类感到困惑,并且无法使用“ git rerere”之类的工具

     

通过将这些文件的'conflict-marker-size'属性设置为32来解决此问题,这将使冲突标记明确。

相关问题