2026-01-02 Delete git gone branches
ローカルブランチのお掃除をしたい。
git branch --mergedを対象にお掃除する戦略があるが、git squash merge したブランチは git branch --merged では出てこない。
gone 状態になったブランチを見れば、squash merge したブランチを検出可能である。
$ git branch -v
add-anchors-for-category 80460dc [gone] feat: Add anchors to category page
...
[gone]がマージ完了して、originから削除されたブランチである。
これらを対象に git branch -Dしてやれば :ok:。
$ git branch -v | grep '\[gone\]' | sed 's/^..//' | cut -d' ' -f1 | xargs git branch -D
Claude Code の場合
anthropics/claude-plugins-official で commit-commands をインストールすると利用可能。
/commit-commands:clean_gone を使うと良い。
/commit-commands:clean_gone Cleans up all git branches marked as [gone] (branches that have been deleted on the remote but still exist locally), including removing associated worktrees.
(plugin:commit-commands@claude-plugins-official)
おまけ:squash merge に対するお気持ち
人類、コミットメッセージをきちんと書くのが困難なので、この方針は割と賛成 // GitHub のマージは基本スカッシュでいいと考えている|myooken https://t.co/8f0KqMV4Dz #zenn
— toshimaru (@toshimaru_e) December 26, 2025