0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

備忘録: Git でリモートで削除されたマージ済みブランチをローカルからも消す

0
Last updated at Posted at 2026-09-13

概要

GitHub で "Automatically delete head branches" を有効にしていると、PR をマージしたとき PR 作成元のブランチがリモートで自動的に消える。
当然ローカルブランチも消したいが、都度ブランチ名を指定するのは面倒なので一発で消えてほしい。

設定

~/.gitconfig
[alias]
    cleanup = !git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -d

使い方

$ git fetch --prune
# または git config --global fetch.prune true を指定して fetch
$ git cleanup

おまけ

この記事を書くために色々調べていたら git-trim に出会った。これでいい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?