LoginSignup
29
32

More than 5 years have passed since last update.

[git]リモートで削除されたブランチがローカルに残っている時、一括で削除する方法

Last updated at Posted at 2014-01-29

GitHubを使っていて、pullrequestがマージされた時にブランチも一緒に消すことが多い。
すると、GitHub上ではブランチは削除されるのだけど、ローカルには残ってしまう。

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/hoge
  remotes/origin/master

上の例だとremotes/origin/hogeが残る。
これを放置していると、remotes/origin/fuga、remotes/origin/piyoと徐々に増殖して行き、いつの間にか大変なことになっている。
そんな時、git fetch --pruneを使うと、リモートで削除されたブランチをガーッと削除してくれる。

$ git fetch --prune
x [deleted]         (none)     -> origin/hoge
x [deleted]         (none)     -> origin/fuga
x [deleted]         (none)     -> origin/piyo

気持ちが良い。
プルーンと聞くと、ミキプルーンの苗木を思い浮かべてしまうので「?」と思い調べてみたら、「余分な枝を切り払う」的な意味だったので納得した。

英語力大事。

29
32
2

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
29
32