I don’t know if it’s the most efficient way but here’s one way of dealing with updating a pull request from a personal branch after upstream/master has been updated.
I update my origin/master:
git checkout master git fetch upstream git merge upstream/master
I switch to my local branch:
git checkout local-branch-name
“Pop” the PR commit back into unstaged:
git reset HEAD^
This will remove the last commit (I usually rebase all my PR commits into one before submitting a PR but you can also specify HEAD~x where x is the number of commits you want to pop back out) and put it back into unstaged.
And then try to merge master into the branch:
git merge master local-branch-name
If it merges cleanly I can proceed with a commit. If it can’t merge cleanly, I stash the unstaged changes, I merge and then pop the stash likewise:
git stash git merge master local-branch-name git stash pop
And then take care of the merge conflicts manually. You will get info on which files are in conflict by doing:
After all of this I can commit and push the branch to GitHub which will update the pull request.