ローカルブランチのお掃除をしたい。

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-officialcommit-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 に対するお気持ち