1. git

git log You May Not Know

will display all your commits with the author and hash. This will be shown over multiple lines per commit. (If you wish to show a single line per commit, look at onelineing). Use the q key to exit the log.

git log

By default, with no arguments, git log lists the commits made in that repository in reverse chronological order – that is, the most recent commits show up first. As you can see, this command lists each commit with its SHA-1 checksum, the author’s name and email, the date written, and the commit message.

commit 87ef97f59e2a2f4dc425982f76f14a57d0900bcf
Merge: e50ff0d eb8b729
Author: Brian
Date: Thu Mar 24 15:52:07 2020 -0700
Merge pull request #7724 from BKinahan/fix/where-art-thou
Fix 'its' typo in Where Art Thou description
commit eb8b7298d516ea20a4aadb9797c7b6fd5af27ea5
Author: BKinahan
Date: Thu Mar 24 21:11:36 2020 +0000
Fix 'its' typo in Where Art Thou description
commit e50ff0d249705f41f55cd435f317dcfd02590ee7
Merge: 6b01875 2652d04
Author: Mrugesh Mohapatra
Date: Thu Mar 24 14:26:04 2020 +0530
Merge pull request #7718 from deathsythe47/fix/unnecessary-comma
Remove unnecessary comma from CONTRIBUTING.md

If you wish to limit your command to last n commits log you can simply pass a parameter. For example, if you wish to list last 2 commits logs.

git log -2

Prettier log In Git

To see the log in a prettier graph-like structure use:

git log --decorate --oneline --graph

Since it’s a pretty big command, you can assign an alias:

git config --global alias.lol "log --decorate --oneline --graph"

To use the alias version:

history of current branch :

git lol

combined history of active branch (HEAD), develop and origin/master branches :

git lol HEAD develop origin/master

combined history of everything in your repo :

git lol --all

Colorize Logs In Git

git log --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr)%C(yellow)<%an>%Creset'

The format option allows you to specify your own log output format:

ParameterDetails
%C(color_name)option colors the output that comes after it
%h or %Habbreviates commit hash (use %H for complete hash)
%Cresetresets color to default terminal color
%dref names
%ssubject [commit message]
%crcommitter date, relative to current date
%anauthor name

Oneline log In Git

git log --oneline

will show all of your commits with only the first part of the hash and the commit message. Each commit will be in a single line, as the oneline flag suggests.If you wish to limit you command to last n commits log you can simply pass a parameter. For example, if you wish to list last 2 commits logs.

git log -2 --oneline

Log search In Git

git log -S"#define SAMPLES"

Searches for addition or removal of specific string or the string matching provided REGEXP. In this case we’re looking for addition/removal of the string #define SAMPLES.

For example

+#define SAMPLES 100000

or

-#define SAMPLES 100000
git log -G"#define SAMPLES"

Searches for changes in lines containing specific string or the string matching provided REGEXP. For example:

-#define SAMPLES 100000
+#define SAMPLES 100000000

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: git log You May Not Know

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories

About

Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password