Question

I have feature/bug-fix branch (say topic) with a bunch of commits and want to present them to my colleagues before merging them into master. I can manually find the common ancestor of my branch and the master branch and compare that to its tip:

$ git diff d0a2eaf..03a025f

Is there a more elegant way to do this?

Was it helpful?

Solution

You can automate finding the common ancestor using git merge-base and that to the tip of your branch:

$ git diff `git merge-base master topic` topic

Or simply use git diff's dot-notation for "Comparing branches" to view changes that occurred on the topic branch since when it was started of the master branch:

$ git diff master...topic

OTHER TIPS

if you current branch is your feature branch, doing a git diff master will do a diff between your current HEAD and the named branch (which is essentially exactly what you're mentioning).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top