Skip to content

Instantly share code, notes, and snippets.

@dephiros
Last active June 19, 2017 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dephiros/f2b7efdd89b539aadd95 to your computer and use it in GitHub Desktop.
Save dephiros/f2b7efdd89b539aadd95 to your computer and use it in GitHub Desktop.
git
# http://stevenharman.net/git-clean-delete-already-merged-branches
# delete branch that is already merge to head
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# delete git branch that is already merge to master
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
# delete git branch that is already merge to origin master
git branch --merged origin/master | grep -v "\*" | xargs -n 1 git branch -d
git revert dcad129d8be57218f1751cda475dd3df6298f79e -m 1

Example merge commit

commit dcad129d8be57218f1751cda475dd3df6298f79e
Merge: 8989ee0 7c6b236
Author: Ben James <ben@example.com>
Date:   Wed Aug 17 22:49:41 2011 +0100

-m specify which parent to revert to. Typically it is the first one. Check with git log to make sure

More Info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment