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?

More than 3 years have passed since last update.

不要なbranchをまとめて削除する方法

Last updated at Posted at 2021-09-16

masterブランチにmerge済みのブランチを、
一気にまとめて消す手順。
(masterを他のブランチ名に読み替えても可能)

手順 1. masterブランチに移動

git checkout master

手順 2. masterブランチ以外のmerge済みのブランチを確認

git branch --mergedでmerge済みのブランチを出力。
grep -v masterで"master"というブランチ名以外のブランチを出力している。

git branch --merged | grep -v master

手順 3. masterブランチ以外のmerge済みのブランチを削除

xargsコマンドで手順 2.の出力結果をgit branch -dに引数として渡す。

git branch --merged | grep -v master | xargs git branch -d
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?