LoginSignup
0
1

More than 5 years have passed since last update.

gitでリモートのマージ済みブランチの最終コミッタを表示させる

Last updated at Posted at 2017-11-01

背景

チームでマージ済みのブランチは削除するというルールがあるんですが、どうも守られていないようで、リモートブランチの数が増えていきました。
BitbucketのGUIではブランチの最終コミッタが表示されないので、ひと目で削除されていないマージ済みのブランチの最終コミッタを見分けたいと思い、gitコマンドでどうにかならないか、調査しました。

スクリプト

for branch in `git branch -a --merged | grep -v master | grep -v develop | grep remotes/origin`
do 
    echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch;
done | sort -r

ワンライナーで書くとこうなります。

$ for branch in `git branch -a --merged | grep -v master | grep -v develop | grep remotes/origin`; do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r

注意

事前にgit fetch --pruneでリモートの削除済みブランチの追跡を切っておかないと、削除済みのブランチまで表示されるので、注意してください。

0
1
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
1