【问题标题】:Do I have to commit a merge to make git-rerere record my conflict resolution?我是否必须提交合并才能使 git-rerere 记录我的冲突解决方案?
【发布时间】:2012-04-02 07:41:00
【问题描述】:

我将git-rerere 用于其预期目的,随着这些分支的发展逐渐记录两个分支(主分支和主题分支)之间的冲突解决方案,而不会创建不必要的合并提交。但是,即使在阅读了 git-rerere 联机帮助页之后,我也不清楚 rerere 何时实际记录了我的冲突解决方案。我检测和解决新合并冲突的标准工作流程是从主题分支执行git merge master,解决冲突,然后暂存所有文件并使用git commit -m "Finished test merge" 提交合并,然后使用git reset --hard HEAD^ 撤消合并,离开仅落后于git-rerere存储的记录分辨率。

但是,这似乎有点愚蠢。创建提交然后撤消它只是为了记录解决方案?在阅读了git-rerere 的手册页后,我仍然不清楚它何时记录了我的决议。仅暂存冲突文件是否足够,或者我是否真的需要在解决冲突后创建合并提交,就像我一直在做的那样?

【问题讨论】:

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


    【解决方案1】:

    来自手册页:

    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 来记录提交。

    【讨论】:

      【解决方案2】:

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

      您必须确保在不留下冲突标记的情况下解决冲突。

      请参阅commit f427869commit bc4caec(2018 年 8 月 28 日)Thomas Gummerer (tgummerer)
      推荐人:Junio C Hamano (gitster)
      (由 Junio C Hamano -- gitster -- 合并于 commit d88949d,2018 年 9 月 17 日)

      commit b9b07ef(2018 年 8 月 28 日)Thomas Gummerer (tgummerer)
      帮助者: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 来解决此问题,这使得冲突标记明确。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-05-30
        • 2014-11-24
        • 1970-01-01
        • 2021-01-20
        • 2015-10-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多