Share your git aliases!
I only have 3 but I feel pretty lost without them.
[alias]
hist = log --oneline --graph --decorate
last = log -1 HEAD
cleanup = git-cleanup
git hist (or git history)
Gives a pretty usable paged git log
git last
Get the last commit details
git cleanup
This one is just a short bash script. It deletes local branches that:
- Have been merged into the current branch you are on (best run from master, or a release branch).
- Do not track a remote branch.
Output

Note: This only deletes the branch. The commits are all still there, so you if for some reason something got lost here (rare with the 2 conditions above), you can always recreate it exactly where it was with
git checkout -b original-branch-name commit-hash-from-the-output.
Script
#!/usr/bin/env bash
# Delete all branches that
# - Have been merged into the current branch you are on (best run from master, or a release branch).
# - Do not track a remote branch.
git branch -r |\
awk '{print $1}' |\
egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) |\
awk '{print $1}' |\
xargs git branch -d
1
Comments
-
I don't have an alias for this, but I have a git-prune-local script I use that I think is similar to your cleanup script, although it only removes merged branches.
git remote prune origin git branch --merged | grep -v "\*" | egrep -v "master|development" | xargs -n 1 git branch -d
0