pecoとかxargsとかawkはきっとみんなインストール済みだと思うけど、まだの人はインストールするといいと思う。
fishでしか確認してないけど普通にどのシェルでも動くんじゃないかな。
develop/master は表示除外してるけどそのへんはお好みでどうぞ。
git --no-pager reflog | awk '$3 == "checkout:" && /moving from/ {print $8}' | grep -vE '(develop|master)' | uniq | head -n 20 | peco | xargs git checkout
aliasを適当に設定してね。ぼくは gitcohistory
にしてる。
~/.config/fish/config.fish
alias gitcohistory='git --no-pager reflog | awk \'$3 == "checkout:" && /moving from/ {print $8}\' | grep -vE \'(develop|master)\' | uniq | head -n 20 | peco | xargs git checkout'
追記
.gitconfig
にセットしたほうがキレイだったのでそうした
.gitconfig
[alias]
co-history = "!git --no-pager reflog | awk '$3 == \"checkout:\" && /moving from/ {print $8}'" | grep -vE '(develop|master)' | uniq | head -n 20 | peco | xargs git co
参考: http://qiita.com/karupanerura/items/502833d970a7cf93ed96