Skip to content

Instantly share code, notes, and snippets.

@alaindet
Last active May 23, 2022 13:43
Show Gist options
  • Save alaindet/9e86d4acb3c9fc5a0b000e3a37bbc800 to your computer and use it in GitHub Desktop.
Save alaindet/9e86d4acb3c9fc5a0b000e3a37bbc800 to your computer and use it in GitHub Desktop.
Git Gotchas

Git Gotchas

Rename a remote branch

git checkout OLD_NAME
git pull
git branch -m OLD_NAME NEW_NAME
git push --delete origin OLD_NAME
git push --set-upstream origin NEW_NAME

One-liner

git checkout OLD_NAME && git pull && git branch -m OLD_NAME NEW_NAME && git push -d origin OLD_NAME && git push -u origin NEW_NAME

Sync with remote branches and list them

git fetch --prune
git branch -r

One-liner

git fetch --prune && git branch -r

List all remote feature branches

git fetch --prune && git branch -r | grep feature

List all remote release branches

git fetch --prune && git branch -r | grep feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment