Last active
September 11, 2020 12:54
-
-
Save viniciusbig/0950b0e2a9e5bc29818c147808d532cf to your computer and use it in GitHub Desktop.
Sync Forks with all branches and tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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