git log --View the contents of the commit log

Use the "git log" command to see the contents of the commit log.

# View the contents of the commit log
git log

The commit log is displayed. You can see the commit ID, author, commit date, and commit message.

commit c0881683c414c3e44ee6e337e295a476a8f7e5ec
Author: Yuki Kimoto <kimoto.yuki@gmail.com>
Date: Fri Oct 16 08:27:22 2020 +0900

    fix echange api string return value bug

commit 45a834a05edb51f412b63d67699ea5179e32e70a
Author: Yuki Kimoto <kimoto.yuki@gmail.com>
Date: Fri Oct 16 07:54:23 2020 +0900

    update MANIFEST

commit 213919f220f8ee6803edfe41b495f6e98c432437
Author: Yuki Kimoto <kimoto.yuki@gmail.com>
Date: Fri Oct 16 07:53:39 2020 +0900

    add type check compiler error tests

Advance the commit log down

Use the "Space" key to move the commit log down.

You can read down, down.

End the display of the commit log

To finish viewing the commit log, type q and press Enter.

Search the commit log

Use the "--grep" option to search the commit log for commit messages. Enter the character string you want to search for in the character string.

git log --grep string

You can retrieve the commit log that matches your search.

I want to know the commit ID immediately before the matched commit ID

Sometimes you want to know the commit ID just before the matched commit ID.

In such a case, you can actually specify the previous commit ID with the notation "Commit ID ^". "Commit ID ^^" can be specified two times before, and "Commit ID ^^^" can be specified three times before.

Let's say the commit IDs that match your search are:

be401600433693794eecbc65ed4b9e787902ed9a

Let's say you want to see the difference from the previous one. Using the notation "commit ID ^", do the following:

git diff be401600433693794eecbc65ed4b9e787902ed9a ^ be401600433693794eecbc65ed4b9e787902ed9a

When do you use git log?

I will introduce the scene where git log is used.

If you want to check after committing with git commit.

If you want to check what kind of branch the branch created by git branch is, you want to use git log to start the commit.

I want to see the beginning of the commit with git log even when switching branches with git checkout.

You can also use git reset to check the commit ID when returning a commit to a certain state.

In addition, if you want to check the commit ID, use it each time.

Associated Information