It's not exactly what you asked, but it can be more useful in your case.
Git has the command git reflog
that allows you to examine the reflog , which is a log (record) of all the times a reference has changed within the repository. HEAD
is a reference, which changes every time you do a checkout , or a commit , so those operations are "registered" in the reflog .
What is better, the most "destructive" changes are also recorded, such as git rebase
or git reset
, which allows you to return to a commit to which you could not return in any other way because the heads of the branches are have moved too.
What you will not see in this way are the git status
, git log
, git add
, and others that you have been able to do not modify references, because those are not saved in the reflog.
On the other hand, the use of history
suggested in other answers does not stop being equivalent to pressing "up arrow" many times in a terminal, because once you finish with the commands of that session, it will continue with those that are stored in the file ~/.bash_history
. The problem is that if you do not find what you were looking for based on "up arrow", it is because it is not saved in that file and therefore it will not appear with history
.
The reason why it could not be saved is that this file is written when you log out. If you had several terminals open, the last one you close will overwrite what you did from others, and so you can lose part of the story.