Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?
Sept 2018: yes: GitHub now explicitly supports “Three-dot and two-dot Git diff comparisons”. See an example here.
keisuke mentions in the comments a similar initiative on Bitbucket.
Original answer 2015:
No: as mentioned in “GitHub compare view for current versions of branches”, GitHub only supports the triple dots (…) range shortcut specification.
That is:
This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.
“
git diff A...B
” is equivalent to “git diff $(git-merge-base A B) B
“.
You can omit any one of , which has the same effect as using HEAD instead.
The official GitHub help mentions this feature as:
The most common use of Compare is to compare branches, such as when you’re starting a new Pull Request.
In that scenario, the PR branch starts from master (or should be rebased on top of master anyway), which means master HEAD is the base between master and the PR branch.
But when the two branches have forked, the comparison is no longer between HEADs
, but between one common ancestor and one HEAD: git diff $(git-merge-base master B) B
.
Note: even if you were to specify two SHA1 directly, as it is clearly documented in “Comparing commits”, that would still do a git diff $(git-merge-base A B) B
.
That would not do a diff directly between the two commits.