When doing code reviews on GitHub, I usually like to review the code locally. This allows me to take advantage of my normal development tools for code navigation, linting and so on.
Given a Pull Request from a topic branch into master, I can get a diff equal to the one on GitHub with:
git diff $(git merge-base topic master) topic
To integrate this nicely with the IDE, my current workflow looks like this:
Change my work tree to match the tip of the PR
git checkout topicSoft reset all changes made in the topic branch
git reset $(git merge-base HEAD master)Add all files to the staging area (this step is very specific to my setup is only necessary so that IntelliJ shows new files in the local changes)
git add -A
However, this doesn't work for the recent partial PR diff that GitHub has with the "New changes since you last viewed" feature (available through the URL template http://github.com/<USER>/<REPO>/pull/<PULL>/files/<START>..<END>)
My naive approach was to simply do a git diff <START>..<END>, but this doesn't work when there is a merge from the master into topic somewhere between <START> and <END>.
In these cases the diff includes all changes made in the master branch since topic diverged, while I'm only interested in changes that will be introduced by merging topic into master.
Somehow GitHub is excluding changes introduced by merges from the base branch.
How can this be reproduced in the command line?