LoginSignup
5
4

More than 5 years have passed since last update.

finishしたらリモートブランチは全部消す

Posted at

git flowでpublishすることでコードレビューの流れを構築することができたわけだが、しかしgit flow finishしても一度publishしたブランチは消えはしない。手動で消す事はできるけど、まあ、忘れますよね。
そこで、すでにマージ済のブランチは容赦無く消えて頂く事にした。慈悲など無い。

もう既にマージされたが残っているリモートブランチに、順番に虚無を送り込んで消して行く

git branch -r --merged | grep -o "feature\/.*" | while read BRANCH; do git push origin :${BRANCH}; done; unset BRANCH;

全部とか言いつつfeature/ブランチに限定しているわけですが。(masterとか消されても困る)

今回はgrepを省くとブランチ名がorigin/feature/***のようになってしまい消せない。grepは対象の絞り込みのみならずこのorigin/というワードを取り除くのにも活用されます。

5
4
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
5
4