Premium lesson

Navigating & Comparing Commits in Git

Git·3 min read·Jan 1, 2025

In Git, navigating and comparing commits allows developers to understand, debug, and collaborate more effectively by tracking the changes made to a codebase over time.

It helps them identify when and why specific modifications were made, and pinpoint the eventual introduction of bugs.

It also allows them to review each other's changes, which is essential for providing feedback, and ensuring code quality and standards.

Reviewing the commit history

To output the complete list of commits present in the history in chronological order, from the newest to the oldest, you can use the git log command:

$ git log

This will output the commits in the following format:

commit <hash>Author: <author>Date:   <date>    <message>

Where:

  • <hash> is a unique hexadecimal string used to reference a specific commit in the history.

icon light bulb key

Unlock the Build CLI Apps in JavaScript & Node.js module

Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.

You get immediate access to:

  • 45 focused lessons across JavaScript, Node.js, npm, and Git
  • 17 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module