Skip to content

Instantly share code, notes, and snippets.

@AndreiRailean
Last active January 31, 2017 01:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiRailean/10e40357cea7c92ca1ae60eacb630806 to your computer and use it in GitHub Desktop.
Save AndreiRailean/10e40357cea7c92ca1ae60eacb630806 to your computer and use it in GitHub Desktop.
Useful Git Snippets
# Checkout and track remote branch
git checkout --track -b local_branch remote/remote_branch
# Delete all merged local branches except for master
git branch --merged master | grep -v master | xargs git branch -d
# Delete all branches from origin remote except master
git branch -a --merged remotes/origin/master | grep -v master | grep "remotes/origin/" | sed 's|remotes/origin/||' | xargs -n 1 git push --delete origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment