Reputation: 1553
My workflow often consists of the following:
Is there any sort of git history that will show me that the thing I was previously working on was branch A?
Upvotes: 4
Views: 112
Reputation: 8875
git checkout -
go to the the previously used branch
I've also set this alias that prints the last 10 branches I've worked on :
[alias]
recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)'
Upvotes: 0
Reputation: 489083
As documented in gitrevisions, the syntax @{-number}
refers to the branch checked out number occurrences ago. This uses the reflogs, specifically the reflog for HEAD
; see Duncan's answer.
(In your particular example you'd want @{-1}
. For git checkout
you can abbreviate this as git checkout -
, but that only works for git checkout
.)
Upvotes: 2
Reputation: 14189
Try:
git branch --sort=-committerdate
or
git for-each-ref --sort=-committerdate refs/heads/
Upvotes: 0
Reputation: 95712
Try:
git reflog
which will list all of your recent actions that changed something, so checkout, rebase, pull, push, etc.
Also it includes all the commit ids, so for example if you did a dozen commit --amend
you can jump back to one in the middle.
Upvotes: 7