Last active
June 19, 2023 08:07
-
-
Save AmaiSaeta/03bc032a2548d022032932109e363cb2 to your computer and use it in GitHub Desktop.
試作:Gitで、削除済みのリモートブランチの追跡ブランチに対する操作を行うalias
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
# 以下を、.gitconfigの「[alias]」セクションに追記する。 | |
# git ls-gone : リモートブランチの削除された、リモート追跡ブランチを一覧する。 FIXME: 順次問い合わせを行っている都合上、遅い。 | |
# git rm-gone : リモートブランチの削除された、リモート追跡ブランチを削除する。 | |
ls-gone = "!f() { git branch --remotes | awk '{ print $1 }' | while read branchname; do git ls-remote --exit-code $(echo $branchname | sed --expression 's|/| |') &>/dev/null; if [[ $? -eq 0 ]]; then continue; fi; echo $branchname; done }; f" | |
rm-gone = "!f() { git ls-gone | while read branchname; do git branch --delete --force ${branchname#*/} && git branch --remotes --delete $branchname; done }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment