Skip to content

Instantly share code, notes, and snippets.

@thatandromeda
Created June 27, 2018 14:41
Show Gist options
  • Save thatandromeda/38fb1546b8f04133b0a61dfd0d6936ae to your computer and use it in GitHub Desktop.
Save thatandromeda/38fb1546b8f04133b0a61dfd0d6936ae to your computer and use it in GitHub Desktop.
git cleanup
# This alias lets you use "git cleanup" in the following scenario:
# - you're on a branch
# - that branch just got merged on the remote
# - you would like to switch to master, update it, and delete your now-useless local branch
# - you don't want to type three almost-identical commands every time you do this thing you do all the time
# Yay! Now you can do the thing in two words.
[alias]
cleanup = "!f() { branch_name=$(git rev-parse --abbrev-ref HEAD); git checkout master; git branch -D ${branch_name}; git pull;}; f"
@jcoyne
Copy link

jcoyne commented Apr 9, 2020

I love this one. Thanks for sharing.

@thatandromeda
Copy link
Author

Yay, I'm glad it works for you!

@thatandromeda
Copy link
Author

Also useful for me:
derpsquish = "!git add . && git commit -a --amend -C HEAD"

(This is for when you committed some stuff, then made a couple of changes that you immediately thereafter thought of which belonged in that commit. It replaces git commit -am"Earlier commit message", git commit -am"derp", then squashing the commits.)

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