http://blog.csdn.net/hansel/article/details/8952967
使用".."(两个点)和"..."(三个点)都可以指定一段git提交范围,它们有什么区别呢?
1.如果是在git log命令中
man git-rev-list可以知道它们的区别。
“r1..r2" 与 "^r1 r2"表示的范围一样,都是可以到达r2但不可以到达r1的所有提交。
如下图的提交历史:
git log F..J 将显示C, G, H, I, J
git log J..F 将显示D, E, F
git log F..M 将显示K, L, M
git log M..F 将显示B, D, E, F
- D---E-------F
- /
- B---C---G---H---I---J
- /
- A-------K---------------L--M
“r1...r2"叫做”symmetric difference“,它与 "r1 r2 --not $(git merge-base --all r1 r2)"表示的范围一样,都是表示可以到r1或者r1,但是不能同时达到两者的提交。
“r1...r2" 与 “r2...r1"表示的是一样的。
还是如上图的git提交历史:
git log F...J 将显示D, E, F, C, G, H, I, J
git log F...M 将显示B, D, E, F, K, L, M
2. 如果是在git diff命令中
参考man git-diff的说明。"r1..r2"表示r1到r2之间的区别,而"r1...r2"表示从r1和r2公共祖先到r2的区别。
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view the changes between two arbitrary <commit>.
git diff [--options] <commit>..<commit> [--] [<path>...]
This is synonymous to the previous form. If <commit> on one side is omitted, it will have the same
effect as using HEAD instead.
git diff [--options] <commit>...<commit> [--] [<path>...]
This form is to view the changes on the branch containing and up to
the second <commit>, starting at a common ancestor of both
<commit>. "git diff A...B" is equivalent to "git diff
$(git-merge-base A B) B". You can omit any one of <commit>, which
has the same effect as using HEAD instead.
$ git diff topic master (1)
$ git diff topic..master (2)
$ git diff topic...master (3)
1. Changes between the tips of the topic and the master branches.
2. Same as above.
3. Changes that occurred on the master branch since when the topic branch was started off it.