git show多くの親コミットがあるコミットの差分は表示されません。git は表示すべきN差分 (N親コミットの数はどこにあるのか) がわからないためです。
競合を手動で解決すると、この diff はコミット メッセージ内に存在するだけで、それ以上のことはありません。
それはどのように可能ですか?
簡単。このマージ コミットmy new contentsでは、単に削除されます。次の 2 つの差分のいずれかで見つける必要があります。
- マージコミットとその最初の親コミットとの差分
- マージ コミットとその 2 番目の親コミットとの差分
最後に、git diff SHA^!役立つはずです。
どのようにそれを行うことができます。
2 つのコミットがあるとしましょう
$> git log --oneline
30917b9 add my new contents
d6a09ba add a.txt
そして最後のコミットはあなたに似ています
$> git show
commit 30917b94b6e6740cacc854e891d67d29195b98c3
Author: b <a>
Date: Fri May 17 00:29:56 2013 +0400
add my new contents
diff --git a/a.txt b/a.txt
index 3be5d25..af49de6 100644
--- a/a.txt
+++ b/a.txt
@@ -1,3 +1,4 @@
old contents
old contents
old contents
+my new contents
次に、誰かが最初のコミットに基づいて変更を行います ( d6a09ba):
commit f6997eae5f40f156897eedfbf058bcf3fe8730b6
Author: b <a>
Date: Fri May 17 00:34:38 2013 +0400
I don't care about new contents
diff --git a/b.txt b/b.txt
new file mode 100644
index 0000000..d099a6a
--- /dev/null
+++ b/b.txt
@@ -0,0 +1 @@
+well, this is a new file
彼はそれをプッシュしようとしましたが、拒否されました:[
$> git push origin
To jws:~/test.git
! [rejected] HEAD -> master (non-fast-forward)
次に、彼はあなたのコミットをプルしてマージを行いました
$> git pull origin master
From jws:~/test
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
a.txt | 1 +
1 file changed, 1 insertion(+)
のようなコミットメッセージですMerge branch 'master' of jws:~/test。次に、ファイルを編集a.txtし、それをステージングに追加し、ステージングをgit add a.txt追加してコミットするとgit commit --amend、出来上がり:
$> git show
commit 51a3f94436cf1a9a763d84acfcf7202f9f2d88ec
Merge: f6997ea 30917b9
Author: b <a>
Date: Fri May 17 00:36:56 2013 +0400
Merge branch 'master' of jws:~/test
の変更については何もありませんa.txtが、差分の 1 つでわかるように変更されています。
$> git diff 51a3f94436cf1a9a763d84acfcf7202f9f2d88ec^2 51a3f94436cf1a9a763d84acfcf7202f9f2d88ec
diff --git a/a.txt b/a.txt
index af49de6..3be5d25 100644
--- a/a.txt
+++ b/a.txt
@@ -1,4 +1,3 @@
old contents
old contents
old contents
-my new contents
diff --git a/b.txt b/b.txt
new file mode 100644
index 0000000..d099a6a
--- /dev/null
+++ b/b.txt
@@ -0,0 +1 @@
+well, this is a new file