如何在git merge commit中列出冲突的文件(父母双方均更改的文件)?

问题描述:

qgit有一个不错的选择,即在合并提交中看到有趣的"文件,其中一个有趣的文件定义为在两个父目录中都有更改的文件.要查看这些文件,相应的命令行是什么?

qgit has the nice option of seeing "interesting" files in a merge commit, where an interesting file is defined as a file that has changes in both parents. What would be the corresponding command line to see such files?

git show --name-status SHA1_of_merge

将向您显示提交信息和在两个父级中修改过的文件( MM ).

will show you the commit message and files modified in both parents (MM).

例如对于提交 d907bf8ef32:合并分支的git.git存储库"jc/index-pack" 我们看到:

e.g. for the git.git repository in commit d907bf8ef32: Merge branch 'jc/index-pack' we see:

$ git show --name-status d907bf8ef327cd47433d4a4bb0a1bb4e96b6e340
commit d907bf8ef327cd47433d4a4bb0a1bb4e96b6e340
Merge: 54dbc1f 3de89c9
…

MM      builtin/index-pack.c
MM      builtin/pack-objects.c
MM      cache.h
MM      csum-file.c
MM      fast-import.c
MM      sha1_file.c

如果您不关心提交消息之类的内容,则git show联机帮助页将您指向用于合并提交的格式: git diff-tree --cc .因此,如果您只想查看提交哈希和有趣的文件",请使用:

if you don't care about commit message and such, the git show manpage points you to the format used for merge commits: git diff-tree --cc. so, if you only want to see the commit hash and "interesting files" use:

$git diff-tree --cc --name-status d907bf8ef327cd47433d4a4bb0a1bb4e96b6e340
d907bf8ef327cd47433d4a4bb0a1bb4e96b6e340
MM  builtin/index-pack.c
MM  builtin/pack-objects.c
MM  cache.h
MM  csum-file.c
MM  fast-import.c
MM  sha1_file.c