Chapter 10: Git History

Git History — the beautiful, powerful timeline that makes Git feel like magic once you learn to read it.

Git history is simply the complete record of every commit ever made in your repository. Every time someone runs git commit, Git adds a new entry to this chain. It’s not just a list — it’s a directed acyclic graph (DAG) of snapshots, each pointing back to its parent(s).

Why care about history?

  • See who changed what and when (blame / accountability)
  • Understand why something broke (bisect bugs)
  • Go back in time to any working version
  • Review team progress
  • Write changelogs / release notes
  • Impress interviewers when they say “show me your commit history”

Let’s build a tiny example repo together so you see exactly what history looks like in practice.

Step 1 – Create a playground with realistic commits

Bash

Now we have 6 commits with a tiny branch & merge.

Step 2 – The Most Important Command: git log

This is your window into history.

Basic view (full details)

Bash

Output looks like (newest first):

text

Too verbose? Let’s make it beautiful and useful.

Step 3 – Pretty & Practical Ways to View History (Daily Drivers in 2026)

1. One-line summary – most used

Bash
text

2. Pretty graph + branches (my personal favorite)

Bash

Or shorter alias (add this once globally):

Bash

Then just run:

Bash

Typical beautiful output:

text

→ See merge bubbles, branch names, HEAD position — gold!

3. Last 5 commits only

Bash

4. Who changed what (blame-style summary)

Bash

5. See actual code changes in history

Bash

Or for one file:

Bash

6. See only file names changed per commit

Bash

7. Statistics – how many lines added/removed

Bash

Example snippet:

text

Step 4 – Even More Powerful History Tools

  • git show → zoom into one commit

    Bash
  • git blame → line-by-line who/when

    Bash

    Shows commit hash + author + date for each line

  • git reflog → your personal undo history (even commits you “lost”)

    Bash
    text

    Super useful when you accidentally reset hard or lose a branch.

Quick Summary Table – Your Git History Cheat Sheet

What you want to see Best Command Why it’s useful
Simple list git log –oneline Fast overview
Branches & merges visualized git lg (alias) or –graph –decorate –all Understand team workflow
Last N commits git log -n 10 –oneline –graph Recent activity
Changes in a commit git show <hash> or git log -p -1 Code review / debug
Who touched a file (line by line) git blame <file> “Who broke this line?”
Personal safety net / undo history git reflog Recover “lost” commits
Stats (lines changed) git log –stat See impact size

Homework for today:

  1. In any repo → run git lg or git log –graph –oneline –decorate –all
  2. Pick a commit hash → git show <hash>
  3. Try git blame on a file with multiple commits

Got the history vision now? Next class — want to learn git bisect (find which commit broke something)? Or git diff across history? Or how to rewrite history safely?

Just tell me — we’re building this together step by step. You’re getting seriously good at Git! 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *