Is there a register of command activity in git?


The idea is to see a list of all the actions or commands that the user has introduced on Git. For example, to know how I ended up committing, to see what commands I have previously entered and to better understand what the system has done.

Normally you have the console as help, in it you can see all the commands that you have used, but I have had situations in which I closed the console and when I opened it again I could not see what commands I had entered.

asked by Mr. Baldan 14.12.2018 в 14:37

3 answers


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.

answered by 14.12.2018 / 17:39

This is not for the git history, but using the command history in Linux you can use the history command and filter the results with the grep command, something like this:

history | grep "git"

If you need to search for something specific, such as what is related to the commando commit you can use:

history | grep "git commit"

All the commands executed by the users are not registered, only the actions that affect the repository. For this there is the git log command. With this you could infer the changes you have had over time.

You can use it like this:

$ git log

commit bac651c6d739341f2e4085619500654ba5950a6e
Author: gustavovelascoh <[email protected]>
Date:   Fri Dec 14 10:38:00 2018 +0000

    Updated .gitignore

commit 2a0afcd7a399e7e3e94e48fd954c976249137b18
Author: gustavovelascoh <[email protected]>
Date:   Fri Dec 14 10:34:01 2018 +0000

    First version of app

commit 44d581be49a0b268ea1d12f7cd5a60d84ddc2e95
Merge: 53a2702 613a787
Author: gustavovelascoh <[email protected]>
Date:   Fri Dec 14 10:30:33 2018 +0000

    Merge branch 'master' of

or with different display options such as:

$ git log --all --graph --oneline --decorate

* bac651c (HEAD -> master, origin/master) Updated .gitignore
* 2a0afcd First version of app
*   44d581b Merge branch 'master' of
| * 613a787 Added .gitignore and yield calculator script
| * f0bb412 Files updated. running version
* | 53a2702 Added configuration file support
* | 56191c3 Displaying seconds in X axis
* 94e143c (tag: v1.0) Added recording application
* 3174c94 Added recording example with unknown duration
* 6f793da Added CAN sniffer class
* 68128fa update utils and record_line
* 05449cb Added support for subprocess in windows
* 38ca880 Data is loaded and plotted
* 8e70927 Initial commit. Server, Recording and partial reading
answered by 14.12.2018 в 15:52

in linux you can use the command history

history | grep git

This will show you the commands that include the word git you can be more specific if you want for example

history | grep git checkout

 doskey /history

With the difference that the search will be manual

answered by 14.12.2018 в 16:09