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.
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 logOn current branchcommit f5b5bd8f9eaa443d4020cbe918x742e7ddd22000Author : 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.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Git on Codecademy
Learn Git & GitHubUse our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.