Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@viniciusbig
Last active September 11, 2020 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniciusbig/0950b0e2a9e5bc29818c147808d532cf to your computer and use it in GitHub Desktop.
Save viniciusbig/0950b0e2a9e5bc29818c147808d532cf to your computer and use it in GitHub Desktop.
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