History or log of commands executed in Git

Is there a way I can keep track of commands I used in Git under Windows? I want to view all the commands that I have applied on my repository.

I want to be able to go back through the command history and figure out the command that caused the problem if one occurred.

Seeing the history of commits would be one thing, but for keeping a history of other actions such as creating a branch or adding a remote, are these tracked?


Solution 1:

You can see the history with git-reflog (example here):

git reflog

Solution 2:

A log of your commands may be available in your shell history.

history

If seeing the list of executed commands fly by isn't for you, export the list into a file.

history > path/to/file

You can restrict the exported dump to only show commands with "git" in them by piping it with grep

history | grep "git " > path/to/file

The history may contain lines formatted as such

518  git status -s
519  git commit -am "injects sriracha to all toppings, as required"

Using the number you can re-execute the command with an exclamation mark

$ !518
git status -s

Solution 3:

If you are using CentOS or another Linux flavour then just do Ctrl+R at the prompt and type git.

If you keep hitting Ctrl+R this will do a reverse search through your history for commands that start with git

Solution 4:

Type history in your terminal. It's not technically git, but I think it is what you want.