You fork a repository on somewhere like GitHub or GitLab and you make some changes. Maybe you want to contribute to an open-source repository. You work on your fork, but in the interim, the repository you forked has had a new release and quite a few new commits.
How do you get those commits from the repository you forked and merge them into your fork? This is where setting an upstream from the forked repository comes in handy.
1. Add an upstream remote
First thing you should do after forking a repository, is adding the source as an upstream remote.
git remote add upstream firstname.lastname@example.org:aurelia/aurelia.git
2. Keep the upstream up-to-date
This will fetch changes from our upstream (the parent repository that we forked from) — if there are any new changes, it will update our upstream.
git fetch upstream
3. Then to update your current repository, you can fetch and rebase
The reason you should use rebase is if you have some local changes, your commit history will be kept clean. If you have ever pulled and merged changes in without rebasing, then you might have seen how messy your history can get.
git rebase upstream/master