How can I get a list of Git branches that I've recently checked out?

佐手、 提交于 2019-12-03 08:30:08

问题


When moving between Git branches I sometimes forget the name of a branch I was recently on. How can I display a list of recently checked out branches/tags/commits?


回答1:


Summary:

You can use Git's reflog to show recent movements: git reflog

Script:

Here's a script you can download and use via git recent from inside any Git repository: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd

Details:

Here's essentially what the script does to make the reflog output more usable:

$ git reflog | egrep -io "moving from ([^[:space:]]+)" | awk '{ print $3 }' | awk ' !x[$0]++' | egrep -v '^[a-f0-9]{40}$' | head -n5
master
stable
fix-stuff
some-cool-feature
feature/improve-everything


来源:https://stackoverflow.com/questions/25095061/how-can-i-get-a-list-of-git-branches-that-ive-recently-checked-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!