Skip to content

Instantly share code, notes, and snippets.

Embed
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 https://github.com/YOUR_USERNAME/REPO_NAME.git
# Check your local copy references
$ git remote -v
origin https://github.com/YOUR_USERNAME/REPO_NAME.git (fetch)
origin https://github.com/YOUR_USERNAME/REPO_NAME.git (push)
# Add a reference to the original repository with…
$ git remote add upstream https://github.com/THEIR_USERNAME/REPO_NAME.git
# Check your changes again with…
$ git remote -v
origin https://github.com/YOUR_USERNAME/REPO_NAME.git (fetch)
origin https://github.com/YOUR_USERNAME/REPO_NAME.git (push)
upstream https://github.com/THEIR_USERNAME/REPO_NAME.git (fetch)
upstream https://github.com/THEIR_USERNAME/REPO_NAME.git (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