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.
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.
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.
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.
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.
Share your thoughts in the comments
Please Login to comment...