Git Log

RaffyRod's avatar
Published May 25, 2023
Contribute to Docs

In Git, the log command is used to track a branch’s commit history. After running, it will display project-related information, such as a detailed commit history, which can be used as a reference to go back in time to a previous version of the project.

  • Use our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.
    • With Certificate
    • Beginner Friendly.
      4 hours
  • Learn about the command line, starting with navigating and manipulating the file system, and ending with redirection and configuring the environment.
    • With Certificate
    • Beginner Friendly.
      4 hours

Example

Below is a short example of how the git log command works. Running git log will show a list of all previous commits on the current branch:

$ git log
On current branch
commit f5b5bd8f9eaa443d4020cbe918x742e7ddd22000
Author : John Doe <[email protected]>
Date: Mon May 22 14:21:03 2023 -0400.

The example log above shows the different elements that make up a commit, but the most useful is the git hash (f5b5bd8f9eaa443d4020cbe918x742e7ddd22000), which can be used to revert our commit changes using the git revert command.

All contributors

Contribute to Docs

Learn Git on Codecademy

  • Use our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.
    • With Certificate
    • Beginner Friendly.
      4 hours
  • Learn about the command line, starting with navigating and manipulating the file system, and ending with redirection and configuring the environment.
    • With Certificate
    • Beginner Friendly.
      4 hours