Update a fork of a repository to keep it up-to-date with the
Add the remote (original repo you forked) and call it
upstream, if you haven’t already done so:
$ git remote add upstream https://github.com/User/original-repo.git
$ git remote add upstream email@example.com:User/original-repo.git
Fetch all branches of remote
$ git fetch upstream
Check out to your fork’s local
$ git checkout master
Rewrite your master with
masterusing git rebase:
$ git merge upstream/master
Push your updates to
$ git push origin master
You may need to
$ git push origin master --force
Edited: 2020-06-18 15:10:23 UTC
In previous version of this post, on step 3, I was using rebase.
$ git rebase upstream/master
Since merge would be a better approach —instead of ’re-writing' the history keeping all the history is better, I updated the post with merge technique.
For more info you can look at : Why you should stop using Git rebase
If you are enjoying my content, maybe you would enjoy buying me a coffee as well.
Just a food for thought.