gcbenison
gcbenison

Reputation: 11963

changes introduced by branch X, since it diverged from branch Y

What's a good, concise, easily-remembered way to ask for "changes introduced by branch X, since it diverged from branch Y"? I often find myself doing this:

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

But it seems like there's got to be a shorthand for that not involving bash-isms.

Upvotes: 1

Views: 39

Answers (1)

torek
torek

Reputation: 490118

The triple-dot revision notation X...Y automatically computes the merge-base of commits X and Y. Normally it means (as gitrevisions notes) "the set of commits reachable from either rev but not from both revs".

For git diff, however, the 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.

Meanwhile, in git diff, plain .. is also altered, and means the same as specifying each revision on either side of the .. separately.

So:

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

is the same as:

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

which is the same as:

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

which is the same as:

git diff --stat master...HEAD

which is the same as:

git diff --stat master...

which is your shortest short-hand.

Upvotes: 3

Related Questions