In this lesson, you will learn how to navigate your project’s timeline by using the git log command to view the metadata of your past snapshots.
Now that you have learned how to create atomic commits, you need a way to review your progress. Think of git log as a diary of your repository. Whenever you want to see the trail of breadcrumbs you have left behind, this command provides a chronological list of every commit you have saved.
Viewing Your History
When you run git log inside your project folder, Git displays a list of your commits in reverse chronological order (the most recent ones appear at the top). For every entry, you will see three critical pieces of information:
- The Commit Hash: A unique, long string of characters (e.g.,
a1b2c3d...) that acts as a digital fingerprint for that specific snapshot. - The Author Details: Your name and email address, confirming who made the changes.
- The Timestamp: The exact date and time the commit was recorded.
- The Commit Message: The descriptive text you wrote to explain the changes in that snapshot.
Your output will look something like this:
commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
Author: Your Name <you@example.com>
Date: Mon Oct 23 14:30:00 2023 -0500
Add initial file structure and project configuration
Navigating the Output
If your project has a long history, git log will open the list inside a pager. You can scroll through the list using your arrow keys or the Spacebar. Once you have finished reviewing your history, you can exit the view by pressing the q key on your keyboard.
By regularly checking your log, you ensure that your history remains clear and that your work is being recorded exactly as you intended. It is the best way to verify that your snapshots are logical and properly documented.
Key Takeaway: The git log command is your primary tool for auditing your project’s evolution by displaying the unique hash, author, timestamp, and message of every commit.