Skip to content

Instantly share code, notes, and snippets.

@KarolAltamirano
Created September 11, 2019 13:50
Show Gist options
  • Select an option

  • Save KarolAltamirano/78f13c0821ba145c8e67b77861f12720 to your computer and use it in GitHub Desktop.

Select an option

Save KarolAltamirano/78f13c0821ba145c8e67b77861f12720 to your computer and use it in GitHub Desktop.
Sync git fork repo
# 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