由分支X引入的更改,因为它与分支Y分开

时间:2014-07-10 17:33:58

标签: git

什么是一个好的,简洁的,容易记住的方式来询问分支X引入的变化,因为它偏离分支Y"?我经常发现自己这样做:

$ git diff --stat $(git merge-base master HEAD)..

但似乎有必要成为不涉及bash-isms的简写。

1 个答案:

答案 0 :(得分:3)

三点修订符号X...Y会自动计算提交XY的合并基础。通常它意味着(如gitrevisions注释)“可以从任何一个转速但不能从两个转速到达的提交集”。

但是,对于git diffmeaning 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...

这是你最短的简写。