LoginSignup
10

More than 5 years have passed since last update.

gitのマージ済みのブランチを整理する

Last updated at Posted at 2014-07-31

マージ済みのブランチをみんな消してくれないので、終わったやつを消すコマンド作った。
適当にrcファイルに入れてください。
マージしても残したいブランチはignore_branchesに追加するとスルーします。

.zshrc
function git-clean-branch() {
    local -a ignore_branches
    ignore_branches=('develop' 'master')
    for b in $(git branch --merged | grep -v '*'); do
        if (( ! ${ignore_branches[(I)$b]} )); then
            git push origin :$b;git branch -d $b
        fi
    done
}

gitリポジトリ内で以下のコマンドを実行すると消してくれます
git-clean-branch

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
10