Git log

The git log command allows you to view all the previous commits in your repository, with the most recent commits appearing first. By default, it shows all the commits of the currently checked out branch.



Tutorials dojo strip

Initial Example

$ git log




LOG Options

OptionDescription
--allShow commits from all branches.
--prettyCustomize the log output format. Possible values: oneline, short, full, fuller, etc.
--graphShow a graphical representation of the commit history.
--authorShow commits by a specific author. Example: --author="Author Name".
-n <number>Limit the number of commits shown. Example: -n 5 to show the last 5 commits.
--sinceShow commits more recent than a specific date. Example: --since="2023-01-01".
--untilShow commits older than a specific date. Example: --until="2023-01-01".
--onelineShow each commit as a single line.
--decorateShow ref names along with the commit message.
--statShow statistics for files modified in each commit.
--patchShow the full diff of each commit.
--name-onlyShow only the names of the files that were changed.
--name-statusShow the names and status of files that were changed.
--abbrev-commitShow only the first few characters of the SHA-1 hash.
--relative-dateShow dates relative to the current time (e.g., “2 weeks ago”).
--reverseShow commits in reverse order.
--grepShow only commits with a commit message matching the given pattern. Example: --grep="fix".
--first-parentShow only the first parent commits of merge commits.




Examples

1. Show All Commits

Shows all the commits of the currently checked out branch.

$ git log

2. Show All Commits from All Branches

Forces Git to show all commits from all branches.

$ git log --all

3. Show Commits with Detailed Information

Displays each commit with detailed information like author, date, and message.

$ git log --pretty=fuller

4. Show Commits with Graph

Shows a graphical representation of the commits.

$ git log --graph

5. Show Commits of a Specific Author

Shows only the commits made by a specific author.

$ git log --author="Author Name"

6. Limit the Number of Commits

Limits the log output to a specified number of commits.

$ git log -n 5

Replace 5 with the desired number of commits.

Scroll to Top