什么是一个好的,简洁的,容易记住的方式来询问分支X引入的变化,因为它偏离分支Y"?我经常发现自己这样做:
$ git diff --stat $(git merge-base master HEAD)..
但似乎有必要成为不涉及bash-isms的简写。
答案 0 :(得分:3)
三点修订符号X...Y
会自动计算提交X
和Y
的合并基础。通常它意味着(如gitrevisions
注释)“可以从任何一个转速但不能从两个转速到达的提交集”。
但是,对于git diff
,meaning is altered:
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
中,普通..
也已更改,并且与分别指定..
两侧的每个修订版相同。 / p>
所以:
git diff --stat $(git merge-base master HEAD)..
与:
相同git diff --stat $(git merge-base master HEAD)..HEAD
与:
相同git diff --stat $(git merge-base master HEAD) HEAD
与:
相同git diff --stat master...HEAD
与:
相同git diff --stat master...
这是你最短的简写。