Created
September 11, 2019 13:50
-
-
Save KarolAltamirano/78f13c0821ba145c8e67b77861f12720 to your computer and use it in GitHub Desktop.
Sync git fork repo
This file contains hidden or 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
| # add remove | |
| git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git | |
| git remote -v | |
| # checkout master and delete other branches | |
| git checkout master | |
| git branch | grep -v master | xargs git branch -D | |
| # sync master | |
| git fetch upstream | |
| git checkout master | |
| git rebase upstream/master | |
| git push | |
| git push --tags | |
| # sync other branches | |
| for brname in `git branch -r | grep upstream | grep -v master | grep -v HEAD | sed -e 's/.*\///g'`; do git branch --track $brname upstream/$brname ; done | |
| git push --all origin | |
| git push --tags origin | |
| # delete all local branches except master | |
| git branch | grep -v master | xargs git branch -D | |
| # delete remote branch | |
| git push origin --delete origin/v2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment