Git:修复合并冲突时获取$ REMOTE,$ BASE和$ LOCAL文件

时间:2015-10-01 15:12:52

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

当我必须修复合并冲突时,我想请求git给我$ REMOTE,$ BASE和$ LOCAL文件(因为选项keepTemporaries似乎不起作用,请参阅{{3} }线程)。有没有命令这样做?

谢谢!

1 个答案:

答案 0 :(得分:2)

来自git help gitrevisions

    :<n>:<path>, e.g. :0:README, :README
        A colon, optionally followed by a stage number (0 to 3) and a colon, followed by a path, names a blob object in the
        index at the given path. A missing stage number (and the colon that follows it) names a stage 0 entry. During a
        merge, stage 1 is the common ancestor, stage 2 is the target branch_s version (typically the current branch), and
        stage 3 is the version from the branch which is being merged.

因此,如果您位于git checkout mybranch; git merge otherbranch的中间,并且conflict.txt上存在冲突,则git show :2:conflict.txt将显示mybranch中文件的版本(您的&#34; $ LOCAL&#34;),git show :3:conflict.txt将显示来自otherbranch的版本(您的&#34; $ REMOTE&#34;),git show :1:conflict.txt将显示提交中的版本由git merge-base mybranch otherbranch(您的&#34; $ BASE&#34;)确定。

对于没有冲突的文件,请使用git show :0:cleanfile.txtgit show cleanfile.txt

相关问题