Help Topic: The Git log Command
Maintained by: mikerb@mit.edu Get PDF
The Git log Command
The git log command provides useful information about a given repository's commit history. It must be executed on the command line somewhere within the directory of the locally checked out repository. More info can always be found by Googling "Git book" and reading the full PDF online free, or just typing git help log anytime on the command line.
The git log command [top]
The git log command provides a log of changes made to the repository across the group of developers. It is incremental in date, and tells you who made the change and when. It should also tell you, in a short description, what changes or fixes were involved for a given log entry. The basic format is this:
$ git log #(invoked somewhere within previously checked out tree)
If there's more than a handful of log entries in the history, the log will open within the less pager program to make it easier to scroll through the commit history; you can quit by pressing 'q' to leave the pager utility. Since the most common entry of interest is the most recent entry, log entries are reported in descending order by commit date and time. You can also choose to display only a limited number of entries:
$ git log -n 3 #(Shows only the 3 most recent entries)
Here is an example from my locally checked out copy of the moos-ivp tree.
$ cd moos-ivp/ $ git log -n 5 commit e3f29da14962544b91d04d105ec31fdb952c0a7c (HEAD -> master, origin/master, origin/HEAD) Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Mon Jan 24 14:03:07 2022 +0000 more minor mods to support wind/arrows git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9948 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf commit fc39961f9fa0f2ef3384d719ae8852f21d0fd2d6 Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Mon Jan 24 01:53:40 2022 +0000 more mods to accommodate XYArrow class in viewer related code git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9947 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf commit b8f71284e2c1d74c80d39808d6f55411cba4fbca Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Sun Jan 23 23:45:30 2022 +0000 added XYArrow class to the geometry library git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9946 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf commit 5bda70c08ac61db3a9d89f6bf82e76193fc17a0c Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Sun Jan 23 00:54:43 2022 +0000 mod to MarineViewer in drawing circles git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9945 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf commit 800beee30f9aad4d9ee2a42b2a7677c4db762fca Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Sat Jan 22 01:36:31 2022 +0000 mod to pMarineViewer to allow multiple viewers to launch using the pAntler aliasing feature git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9944 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf
The comments in the log entries are important, and are generated upon a commit to the tree. In the case of the git-based mirror of the SVN tree, these comments include information about the corresponding SVN revision.
You have to use your own judgement in striking a balance between quick and convenient commits with minimal comments, and more verbose commits which take more time. At some point you may need the comments of your log to help you revert changes or just remind yourself when something key changed in the history.
Knowing exactly what files changed for a given commit/log entry [top]
In the git log example above, the entry for SVN revision number 9948 (by the Git-SVN relational comment) looks like:
commit e3f29da14962544b91d04d105ec31fdb952c0a7c (HEAD -> master, origin/master, origin/HEAD) Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Mon Jan 24 14:03:07 2022 +0000 more minor mods to support wind/arrows git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9948 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf
This shows the comment entered by the person committing the change, but what really changed in this commit? It would be good to at least know what files are involved. This can be done using the git show command, as follows:
$ git show --name-only e3f29da14962544b91d04d105ec31fdb952c0a7c commit e3f29da14962544b91d04d105ec31fdb952c0a7c (HEAD -> master, origin/master, origin/HEAD) Author: mikerb <mikerb@7b6de600-d9ab-45c9-a1ca-e8145d3c6daf> Date: Mon Jan 24 14:03:07 2022 +0000 more minor mods to support wind/arrows git-svn-id: https://oceanai.mit.edu/svn/moos-ivp-aro/trunk@9948 7b6de600-d9ab-45c9-a1ca-e8145d3c6daf ivp/src/lib_geometry/VPlug_GeoShapes.cpp ivp/src/lib_geometry/XYArrow.cpp ivp/src/pMarineViewer/PMV_Viewer.cpp
To remove the commit summary headers and show only the modified files, add the --pretty="" argument:
$ git show --pretty="" --name-only e3f29da14962544b91d04d105ec31fdb952c0a7c ivp/src/lib_geometry/VPlug_GeoShapes.cpp ivp/src/lib_geometry/XYArrow.cpp ivp/src/pMarineViewer/PMV_Viewer.cpp
Document Maintained by: mikerb@mit.edu
Page built from LaTeX source using texwiki, developed at MIT. Errata to issues@moos-ivp.org. Get PDF