After basic snapshotting of a repository, following commands are used to get it’s commit history.
- git log
- git shortlog
- git diff
Now, we will discuss each command and its different available options.
git log: As the name suggests, this command shows commit logs. It is a command which allows you to view information about the previous commit. Unlike git status command, it only inspects the history of committed repository.
- git log –all or git log: This command displays all commits.
- git log -n “limit”: This option helps to filter the commit history by applying the limit. Replacing “limit” with a number of commits will limit output as n most recently committed ones.
- log –author=”name”: This option limit the output to commits by particular author “name”.
- git log –committer=”name”: This option limit result to commits that were committed by that individual.
- git log -p: This option shows the most detailed view of history. Here p stands for patch.
- git log –oneline: This option is used to get bare information in a single line per commit.
- git log –stat: This option helps to view the summary of changes made in each commit.
- git log “file”: This option display commits that include specified file.
- git log –before(or –after) “date”: This limits the commits to those within a given date range. The date is specified as string in “yyyy-mm-dd” format.
- git log –after “date” –before “date”: This option specifies a date range.
git shortlog: This command is “Sub-command” of git log as it summaries git log output. Each commit is grouped by author and title.
- git log -n
–numbered: It display the output according to number of commits per author.
- git log -s
–summary: This option suppresses commit description
- git log -e
–email: This option displays the email address of each author.
- git log -c
–committer:m This option shows committer identities instead of authors.
- git log “revision range”: Displays commits in specified revision range.
git diff: This command is used to compare different versions of the file or in other words, it shows the changes between the commits, working tree, branches, files, etc.
Summarizing: We learned that a git log command is a basic tool that is used to go through the history of commits. git log is a running record of commits. git shortlog is just a subcommand of git log- summarizing the output of git log. We have just described git diff command as it one of the most advanced options of git.
- Digital Evidence - How to use FTK for examining evidence
- Centralized vs Distributed Version Control: Which One Should We Choose?
- Why Should I Learn Coding?
- How to call PHP function on the click of a Button ?
- Difference between Organic Search and Paid Search
- Routing Path for ExpressJS
- p5.js | noLoop() Function
- p5.js | parent() Function
- HTML | input maxlength Attribute
- HTML | DOM Output value Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.