7
8

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 5 years have passed since last update.

Git でマージ済みのブランチを対話式に削除する

Posted at

ひとつひとつ確認しながらマージ済みブランチを消したい時に。

~/.gitconfig
[alias]
  delmerged = "!f() {\
    IFS=$'\n';\
    for b in `git branch --merged | grep -v '*' | grep -v 'master' | sed -e s/' '/''/g`;\
    do\
      /bin/echo -n \"[ $b ] remove this branch ? [y/n] \";\
      read ANSWOR;\
      if [[ ${ANSWOR} == 'y' ]]; then\
        git branch -D $b;\
      fi\
    done;\
    git branch;\
  }; f"

もっと綺麗に書けそう。

関連記事: Git でマージ済みのブランチを一括削除する #git - Qiita

7
8
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
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?