Skip to content

Instantly share code, notes, and snippets.

@htulipe
htulipe / gist:ba250e1c9231fad05e2a
Last active July 11, 2019 11:58 — forked from nikreiman/gist:5458386
Clean up local branches that are already on master (credit to original gist)
function git-branch-current() {
printf "%s\n" $(git branch 2> /dev/null | grep -e ^* | tr -d "\* ")
}
function git-branch-cleanup() {
local currentBranch=$(git-branch-current)
local otherBranch=
for otherBranch in $(git branch | grep -v $currentBranch) ; do
printf "Branch %s:\n" "$otherBranch"
printf " HEAD commit is: %s\n" "$(git log --oneline -n 1 $otherBranch)"