我想查找影响或涉及给定文件的所有合并提交。列出影响文件的合并提交
为了背景,有人在合并时错误地解决了冲突,并且团队没有注意到几天。此时,许多其他不相关的合并已经发生(我们中的一些人一直宁愿不使用rebase,或者事情会更简单)。我需要找到“错误”的合并提交,因此可以检查以确定还有哪些可能已被还原(当然,以及确定和惩罚有罪)。
的情况是这样的:
$ echo First > a.txt && git add a.txt && git commit -m 'First commit'
$ git branch branch1
$ echo "Second: main-branch" >> a.txt && git commit -a -m 'Commit on master'
$ git tag a1
$ echo "Third: main" >> a.txt && git commit -a -m 'Other commit on master'
$ git checkout branch1
$ echo "Second: on branch1" >> a.txt && git commit -a -m 'Commit on branch'
$ git tag b1
...所以现在有冲突的改变发生在主机和BRANCH1到A.TXT。
$ git checkout master
$ git merge branch1
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
Automatic merge failed; fix conflicts and then commit the result.
$ cat a.txt
First
<<<<<<< HEAD:a.txt
Second: main-branch
Third: main
=======
Second: on branch1
>>>>>>> branch1:a.txt
$ vi a.txt
# ...
$ cat a.txt
First
Second: on branch1
$ git add a.txt
$ git commit -m 'Merge commit'
......换句话说,决议是“拿他们的”。现在,该图如下所示:
$ git log --graph --branches --format='%h %s %d'
* fefb623 Merge commit (refs/heads/master)
|\
| * 93e065e Commit on branch (refs/tags/b1, refs/heads/branch1)
* | cf4d12b Other commit on master
* | 6fade67 Commit on master (refs/tags/a1)
|/
* 07545ea First commit
此时,a.txt的错误版本在master上。 a1中的版本是我们想要的,但是b1版本已经提交。到目前为止,我已经试过:
$ git log --decorate --oneline a.txt
93e065e (refs/tags/b1, refs/heads/branch1) Commit on branch
07545ea First commit
好了,既不A1也不是合并提交出现。
$ git log --decorate --oneline --follow a.txt
...
这显示了我在两个分支上的一切,但仍然省略了合并提交。
$ git log --oneline --graph --decorate a1..master
...
这当然是“一切都在主人不在A1”,在这个玩具例如工作,但在我的实际情况给我最近所做的所有合并(并没有迹象表明其中一个感动A.TXT) 。
我可以合理化文件历史中a1的消失,因为合并选择忽略该变化(至少在我认为git关心的意义上)。但是,如何找到影响a.txt的所有合并提交?这甚至可能没有手动检查所有可信的合并提交?
提交日志不显示合并,因为它与第一父提交,这是你从合并分支的比较;然后git认为没有文件被修改 – CharlesB 2012-04-16 20:20:26