The World’s Largest Online Community for Developers
I have gone through all the steps in the article creating-a-pull-request-from-a-fork. The PR has now been merged
upstream. What is the best way to proceed and update the github fork (
origin) and local repositories?
Currently I delete the branch on the
origin, delete the branch locally. Then do a fetch / merge from
upstream to local and push back to the fork. It works but feels crude. Any hints or tips appreciated. Thank you.
Local git commands after the PR is accepted. The branch on origin deleted on the website:
git checkout master git branch -D branch_name git fetch upstream git merge upstream/master git push origin
git fetch --all git checkout master git merge upstream/master --ff-only git push origin
This works if you are doing your work on feature branches and not on your master. So don't commit/push your work on your master. (Also don't merge your work to your master.)
The "ff-only" forces a fast forward merge and so you're sure the masters are in sync without additional (and unwanted) merge commits. Those merge commits are unwanted are they are also not on the upstream.
If you are committing/pushing on your master (would not recommend it), then your delete-master approach is a good strategy, but be aware you could throw away something unwanted! There is no guarantee that all expected commits are in upstream/master when trowing away origin/master.
If you're doing this regularly, I would recommend to create a git alias :)