Created
March 26, 2023 20:53
-
-
Save emyasnikov/34b8513bdb69007ca7c6ffd857716e77 to your computer and use it in GitHub Desktop.
Git command to remove gone branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
gone = ! "git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == \"[gone]\" {print $1}' | xargs -r git branch -D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git config --local include.path ../.gitconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mainly inspired by https://www.erikschierboom.com/2020/02/17/cleaning-up-local-git-branches-deleted-on-a-remote/