Sync a fork of a repository to keep it up-to-date with the upstream repository.
List the current configured remote repository for your fork.
git remote -v
Specify a new remote upstream repository that will be synced with the fork. (track)
git remote add upstream [email protected]:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Verify the new upstream repository you've specified for your fork.
git remote -v
Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.
git fetch upstream
git checkout master
Now we have two options to update local branch master.
- Merge changes from upstream/master into master brach
- Rebasing master branch from upstream/master (cleaner history)
Merge from upstream/master
git merge upstream/master
Rebase from upstream/master
git rebase upstream/master