Branch to Branch Compare: Compares to Master Instead

Greetings - 

It seems that Branch to Branch compares don’t work correctly - or as least not intuitively.

I created an interactive example here:

https://github.com/gojimmypi/CompareCheck/blob/master/README.md

and illustrated in the picture below:

I did receive this helpful explanation from github support (who referred me here):

As weird as it might seem, what you are seeing is actually expected behaviour when using GitHub’s website to compare branches.

 

We show what’s called a “three-dot diff” which is the difference between the latest commit on the HEAD branch and the last common ancestor commit with the base branch.

 

Here are the commits on the head branch CompareBranchTwo:

 

https://github.com/gojimmypi/CompareCheck/commits/CompareBranchTwo

 

Here are the commits on the base branch CompareBranchOne:

https://github.com/gojimmypi/CompareCheck/commits/CompareBranchOne

 

And their last common ancestor commit is commit f329afb, so our compare view is showing the change that was brought to CompareBranchTwo after commit f329afb, which is commit 30337cc, and this is what you saw in the compare view:

https://github.com/gojimmypi/CompareCheck/commit/30337cc6db008714b04573f0d6c5f2216af99502

We are aware that this can be confusing, and in your case it is particularly non-intuitive. Most people expect to see a “two-dot diff”, which would show the changes between the two most recent commits on each branch.

Unfortunately there is no way to choose which diff to show on GitHub’s interface.

If you’d like, you can merge the base branch back into the HEAD branch (merge CompareBranchOne into CompareBranchTwo). That updates the last common ancestor and would be more likely to show you what you’re expecting to see there.

I believe our engineers are aware of this confusion, and they might consider expanding the feature in the future, but it’s very hard to say if or when will this change take place.

Hope this helps clear things up and please let us know if you have any other questions.

And so in the end I’m just posting this in case someone else runs into this issue (perhaps has an alternative solution?). I suppose this is also a feature request: to be able to compare two branches using the web interface. 

Cheers

7 Likes