完整文檔是在這裏:https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html
假設你有一個回購,看起來像這樣:
base - A - B - C - D (master)
\
\- X - Y - Z (myBranch)
驗證回購狀態:
> git checkout master
Already on 'master'
> git status ; git log --oneline
On branch master
nothing to commit, working directory clean
d9addce D
110a9ab C
5f3f8db B
0f26e69 A
e764ffa base
和myBranch:
> git checkout myBranch
> git status ; git log --oneline
On branch myBranch
nothing to commit, working directory clean
3bc0d40 Z
917ac8d Y
3e65f72 X
5f3f8db B
0f26e69 A
e764ffa base
假設您位於myBranch上,並且您只想更改SINCE master。使用雙點版本:
> git log --oneline master..myBranch
3bc0d40 Z
917ac8d Y
3e65f72 X
三點版本提供了從主刀尖到myBranch刀尖的所有更改。但是,請注意,共同提交不包括B:
> git log --oneline master...myBranch
d9addce D
110a9ab C
3bc0d40 Z
917ac8d Y
3e65f72 X
請注意:git log
和git diff
不同的表現!行爲是不完全相反,但幾乎:
> git diff master..myBranch
diff --git a/rev.txt b/rev.txt
index 1784810..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-D
+Z
> git diff master...myBranch
diff --git a/rev.txt b/rev.txt
index 223b783..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-B
+Z
所以,雙點版本示出了從主站(即d)的前端的DIFF到尖端myBranch(Z)的。三點版本顯示了從myBranch(即B)到myBranch(Z)尖端的差異。
相關:【如何獲得Git中的一個分支的變化(http://stackoverflow.com/questions/53569/how- git) – 2012-03-15 18:09:32