By default when you use the git log command without any options, you would see details for each commit in multiple lines with details such as
- 40-character long commit hash (where the head is pointing)
- Author details, username followed by the author email ID
- Date
- Commit comment
% git log
commit 6ac92d6dece8c15b9472da2590a23f58ff48b4f9 (HEAD -> main)
Author: c2c
Date: Tue Jan 24 18:14:47 2023 +0000
4th commit
commit 06250f0b1cdb7054863f1307d6e66fa8fadda81d
Author: c2c
Date: Tue Jan 24 18:14:34 2023 +0000
3rd commit
commit 27125141f5e0d692e80df0c3113d68334523e539
Author: c2c
Date: Tue Jan 24 14:21:48 2023 +0000
2nd commit
commit a3e24f41e70dec79395c730d68bf26ce64dd7444
Author: c2c
Date: Tue Jan 24 14:21:38 2023 +0000
1st commit
This could easily become hard to read when there are multiple branches and lots of commits.
You can easily make the commit logs to be one/line by using the option --oneline
% git log --oneline
6ac92d6 (HEAD -> main) 4th commit
06250f0 3rd commit
2712514 2nd commit
a3e24f4 1st commit
As you may see that with --oneline option, the commit logs are readable but miss a lot of crucial information such as commit time, author, etc.
Ways to show git commit log in a better way
Example 1: Using pretty formatting
Let's try to get all the information that we need in one line with pretty format options,
% git log --graph --pretty=format:'%h - %s (%cr) - %an'
* 6ac92d6 - 4th commit (25 minutes ago) - c2c
* 06250f0 - 3rd commit (25 minutes ago) - c2c
* 2712514 - 2nd commit (4 hours ago) - c2c
* a3e24f4 - 1st commit (4 hours ago) - c2c
%h -> abbreviated commit hash
%s -> subject (commit message)
%cr -> committer date, relative
%an -> author name

Example 2: Adding Colors
% git log --graph --pretty=format:'%Cred%h%Creset - %Cblue%s%Creset (%cr) - %Cblue%an%Creset'
* 6ac92d6 - 4th commit (36 minutes ago) - c2c
* 06250f0 - 3rd commit (37 minutes ago) - c2c
* 2712514 - 2nd commit (4 hours ago) - c2c
* a3e24f4 - 1st commit (4 hours ago) - c2c
Color Options
- %Cred: Set red color
- %Cgreen : Set green color
- %Cblue: Set blue color
- %Creset : To reset the color

Example 3: Creating an alias for the log formatting in bash/zsh profile
Na! There is no way one can remember or type such huge formatting strings each time you want to see the commit logs. It's always better to come up with your preferred way of a formatting string and add them as an alias to the bash/zsh profile,
Open the .zshrc file or the .bash_profile file and create an alias like below,
alias gitlog1="alias gitlog1="git log --graph --pretty=format:'%Cred%h%Creset - %Cblue%s%Creset (%cr) - %Cblue%an%Creset'"
alias gitlog2="git log --graph --pretty=format:'%h - %s (%cr) - %an'"
Invoke custom git log alias,
% gitlog1
* 6ac92d6 - 4th commit (44 minutes ago) - c2c
* 06250f0 - 3rd commit (44 minutes ago) - c2c
* 2712514 - 2nd commit (5 hours ago) - c2c
* a3e24f4 - 1st commit (5 hours ago) - c2c
Custom multiline log example
Use the %n option to add a newline,
% git log --graph --pretty=format:'Commit: %h %nComment: %s %nDate:%ci (%cr) %nAuthor Name: %an %nAuthor Email:%ae %nCommenter Name:%cn %nCommenter Email:%ce'
* Commit: 6ac92d6
| Comment: 4th commit
| Date:2023-01-24 18:14:47 +0000 (54 minutes ago)
| Author Name: c2c
| Author Email:c2c@c2c.com
| Commenter Name:c2c
| Commenter Email:c2c@c2c.com
* Commit: 06250f0
| Comment: 3rd commit
| Date:2023-01-24 18:14:34 +0000 (54 minutes ago)
| Author Name: c2c
| Author Email:c2c@c2c.com
| Commenter Name:c2c
| Commenter Email:c2c@c2c.com
* Commit: 2712514
| Comment: 2nd commit
| Date:2023-01-24 14:21:48 +0000 (5 hours ago)
| Author Name: c2c
| Author Email:c2c@c2c.com
| Commenter Name:c2c
| Commenter Email:c2c@c2c.com
* Commit: a3e24f4
Comment: 1st commit
Date:2023-01-24 14:21:38 +0000 (5 hours ago)
Author Name: c2c
Author Email:c2c@c2c.com
Commenter Name:c2c
Commenter Email:c2c@c2c.com
More Options:
- %ci -> Commit time in ISO format
- %cn -> Commiter name
- %ce -> Commiter email
Also do checkout the git doc page for pretty formatting: https://git-scm.com/docs/pretty-formats/2.39.0
Have Questions? Post them here!
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- Github: How to Invite Collaborators
- Git Commit - Author identity unknown, Please tell me who you are email
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Get List of all local branches git command
- Git Revision Questions Before the Interview
- git fatal: Authentication failed error [fix]
- How to Install Git on Ubuntu Linux
- GitHub: How to Search Code
- How to change Git Default Author and Committer details in Eclipse
- How to check your installed version of Git
- Install GitHub Command Line Tool on Mac
- How to Merge Branch into Master Branch
- Perform an Empty Commit in Git without anything in Staging Area
- Git Fix: fatal: refusing to merge unrelated histories Error
- How to undo last Git Commit on Local Repository?
- git command to remove/unstage files from staging area
- Step-by-Step: Setting up Docker + Ubuntu Linux + Git + GitHub Tutorial
- Remove git config at Local, Global or System Levels?
- Fix [oh-my-zsh] Cant update: not a git repository
- Git Config Command - A Deep Dive
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- How to change directory in Git bash
- 5 ways to pop out a Chat in Microsoft Teams - Teams
- Customizing Notepad++ New Document Line Encoding: CR/LF/CR LF - NotepadPlusPlus
- Microsoft Teams change default language - Teams
- How to install XML Tools Plugin Notepad++ - NotepadPlusPlus
- Facebook Thanks for stopping by! We hope to see you again soon. - Facebook
- How to change the System Settings Sidebar icon size Mac Ventura 13 - MacOS
- Change Max and Min Value of Android Seekbar Programmatically - Android
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files - Java