git log command

The git log command allows us to see information about all previous commits and status of the head. Each commit has a message attached to it (a commit message), and the git log command prints information about the most recent commits, like their time stamp, the author, and a commit message. This command helps us keep track of what we have been doing and what changes have been saved.

Bash

git log

The above command is listing all the recent commits. Each commit contains the unique commit-id, which is generated by the SHA algorithm.

git log command

Note: Press q key on the keyboard to exit from the git log command view.

Limit on git log

By default, if no argument passed, Git log shows the most recent commits first. We can limit the number of log entries displayed by passing a number as an option, such as -3 to show only the last three entries.

Bash

git log -3
or
git log -n3

git log --oneline

The oneline option is used to display the output as one commit per line, i.e. more concise way of listing the commits.

It will be used as follows:

Bash

git log --oneline

So, usually we can say that the --oneline flag causes git log to display: