2011-07-15 37 views
8

說我有,git的差異獨特的合併提交

 A topic 
    /\ 
D---E---F master 

我可以很容易地通過做

git diff D..E --name-status 

和同爲E-F和E-A獲得d-E的差異。

提交F是一個合併提交,並說它有衝突。它通過修改foo.bar來解決。 goo添加了foo.bar,然後提交了合併提交。合併衝突已解決。

現在foo.bar的更改僅在提交F中存在。如何獲取該差異?

有沒有辦法得到合併提交中唯一引入的文件的差異?

回答

7

git show上的合併提交將顯示更改沒有在其父母的任何。例如:

$ echo 123 > file1.txt 
$ git add file1.txt 
$ git commit -am '123' 

$ git checkout -b test 
$ echo 1234 > file1.txt 
$ git commit -am '1234' 

$ git checkout HEAD~ -b test2 
$ echo> file1.txt 
$ git commit -am '0123' 

$ git merge test 
$ echo> file1.txt 
$ git add file1.txt 
$ git commit -am 'Merge test' 

$ git show 
commit f056a1c91d76c8dfce60a03122494dce92c1e161 
Merge: 489f1d3 fcfd2bc 
Date: Fri Jul 15 20:30:17 2011 -0500 

    Merge test 

diff --cc file1.txt 
index 40381e2,81c545e..3521a84 
--- a/file1.txt 
+++ b/file1.txt 
@@@ -1,1 -1,1 +1,1 @@@ 
-
-1234 
+
0

不確定「合併提交中唯一引入的」文件的含義。該文件必須在之前存在,否則不會有衝突。而「foo.bar的更改只存在於提交F中」也不完全正確。提交不包含更改。您可以看到foo.bar diff與其他任何內容完全相同:git diff E Fgit diff A F,具體取決於您要遵循的分支。