Skip to content

Instantly share code, notes, and snippets.

@AmaiSaeta
Last active June 19, 2023 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmaiSaeta/03bc032a2548d022032932109e363cb2 to your computer and use it in GitHub Desktop.
Save AmaiSaeta/03bc032a2548d022032932109e363cb2 to your computer and use it in GitHub Desktop.
試作:Gitで、削除済みのリモートブランチの追跡ブランチに対する操作を行うalias
# 以下を、.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