Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sync Forks with all branches and tags
# Create your own fork/copy of the target repository using the FORK button.
# Clone/download it to local machine with…
$ git clone
# Check your local copy references
$ git remote -v
origin (fetch)
origin (push)
# Add a reference to the original repository with…
$ git remote add upstream
# Check your changes again with…
$ git remote -v
origin (fetch)
origin (push)
upstream (fetch)
upstream (push)
# Sync it
# Always keep your local copy of repository updated with the original repository.
# Before making any changes and/or in an appropriate interval, run the following commands carefully to update your local repository.
# fetch all remote repos and delete any deleted remote branches
$ git fetch --all --prune
# switch to `master` branch
$ git checkout master
# reset local `master` branch to match `upstream` repo's `master` branch
$ git reset --hard upstream/master
# push changes to your forked repo
$ git push origin master
# you can push everything, instead of just master
git push --all origin
# you can sync all tags with…
git push --tags origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment