Git commands

git log

git log: display the commit log (history).

The git log command is used to display the commit history of a Git repository. It shows a list of all the commits made to the repository, along with information about each commit, such as the commit hash, author, date, and commit message. This command is extremely useful for understanding the history of a project, tracking changes over time, and identifying specific commits that introduced bugs or added features.

By default, git log displays the commits in reverse chronological order, with the most recent commit appearing first. Each commit is identified by its unique hash, which is a 40-character string that uniquely identifies the commit. The commit message is a brief description of the changes made in that commit, which can help you understand the purpose of each commit.

There are many options you can use with git log to customize the output, such as filtering by author or date range, showing only certain branches, or displaying the changes introduced in each commit. Learning to use git log effectively can greatly enhance your ability to navigate and understand the history of a Git repository.

Tip: Some Git commands, such as git log, may put your terminal into pager mode, which is designed for browsing long lists. In this mode, you can scroll through the output using the and arrow keys on your keyboard (or PageUp and PageDown to scroll faster). To exit pager mode, press q.

Examples

Display the commit history using a standard view:

git log

Display the commit history with abbreviated commit hashes and a simplified format:

git log --oneline

Display the commit history as a graph, showing branches and merges:

git log --graph

Display the commit history for a specific file:

Note that the special -- option is used to tell Git that all the following arguments are file paths. This is necessary to avoid ambiguity when a file path may be mistaken for a branch or commit.

git log -- path/to/file.txt

Display commits within a specific date range:

git log --since="2023-01-01" --until="2023-01-31"

Display the commit history for a specific branch:

git log new-blog-design-branch

Display the commit history between two commits:

git log 9ds73k2..5ka4j3d
© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code