🔥 0
0
Lesson 5 of 10 20 min +125 XP

Viewing History

One of Git's superpowers is letting you travel through time. Let's learn how to explore your project's history!

Viewing Commit History

To see all your commits:

git log

This shows each commit with:

  • The full commit hash
  • Author name and email
  • Date and time
  • Commit message

Compact View

For a shorter view, use:

git log --oneline

This shows one commit per line with just the short hash and message.

Reading the Log

commit a1b2c3d (HEAD -> main)
Author: You <you@email.com>
Date:   Mon Jan 15 10:30:00 2024

    Add user authentication feature

commit f4e5d6c
Author: You <you@email.com>
Date:   Sun Jan 14 15:20:00 2024

    Create initial project structure

The HEAD -> main tells you which commit you're currently on.

Comparing Changes with Diff

To see what changed between versions:

# Changes in working directory (not yet staged)
git diff

# Changes that are staged
git diff --staged

# Compare two commits
git diff a1b2c3d f4e5d6c

Understanding Diff Output

- This line was removed
+ This line was added
  This line is unchanged
  • Red (-) lines were removed
  • Green (+) lines were added
  • White lines provide context

Try It Out!

Use the interactive history explorer below.

Visual Mode: Click on commits in the graph to see what changed Command Mode: Use git log and git diff to explore

Try clicking different commits to see how your project evolved over time!

Saving Snapshots