how to keep your Git-Fork up to date

29 Dec 2018

When it comes to the situation that you fork a repository and you contribute to
it, then it could happen that your fork and the upstream are not in sync
anymore. So the goal is, that you get a current version of the upstream
repository and then you can merge the new changes into your fork, right? Okay!
Let’s get started.

4. Keep the upstream updated

Now as we have both urls tracked, we can update the two sources independently. With

$ git fetch upstream

5. Merge/Rebase your work with the upstream repository

Then you can just merge the changes.

$ git merge upstream/master master

With that, you merge the latest changes from the master branch of the upstream
into your local master branch. If you like, you can also use git pull, which is
nothing else than fetching and merging in one step.

Pro Tip: The best way in my eyes is, to rebase because that fetches the
latest changes of the upstream branch and replay your work on top of that. Here
is, how it works: