Skip to content

Instantly share code, notes, and snippets.

@hasselmm
Last active January 5, 2021 17:59
Show Gist options
  • Save hasselmm/b73c0b230bf4ac8f3bfbd501377c3d33 to your computer and use it in GitHub Desktop.
Save hasselmm/b73c0b230bf4ac8f3bfbd501377c3d33 to your computer and use it in GitHub Desktop.
Automatically delete branches that have been merged

Automatically delete branches that have been merged

Add the following line to your git configuration:

$ git config alias.housekeeping
!f() { git checkout -q ${1:-main} && git branch --merged | grep -v ^* | xargs -n1 -r git branch --delete; }; f

After merging branches run:

$ git pull
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
...
$ git housekeeping
Branch improvement/proper-resolver-class entfernt (war 0f0ab34).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment