我怎样才能得到我最近签出的git分支清单? [英] How can I get a list of git branches that I've recently checked out?

查看:96
本文介绍了我怎样才能得到我最近签出的git分支清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git分支之间移动时,我有时会忘记我最近所在分支的名称。如何显示最近签出的分支/标记/提交列表?

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?

推荐答案

总结:



您可以使用git的reflog来显示最近的移动: git reflog

下面是一个脚本,您可以从任何git仓库中通过 git recent 下载并使用脚本:https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd

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

基本上,脚本的作用就是让reflog输出更加可用:

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]++' | head -n5
master
stable
fix-stuff
some-cool-feature
feature/improve-everything

这篇关于我怎样才能得到我最近签出的git分支清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆