Git Topics (9)Tap to view
    Git·Version Control·Topic 3 of 9

    Git History & Diffs

    Examine modification history, view commit messages, compare branches, and track line changes.

    1. Viewing History and Diffs

    1. git log

      What it doesDisplays detailed commit history with the author name, date, and message

      When to use itto review the full history of the current branch

      Examplegit log

    2. git log --oneline -10

      What it doesOne-line summary history for each commit of the last 10 records

      When to use itto take a quick look at your recent edit history

      Examplegit log --oneline -10

    3. git log --oneline --graph --decorate --all

      What it doesDisplays a visual tree showing the branches and merging of all branches

      When to use itto understand the structure of complex history and the paths of parallel branches

      Examplegit log --oneline --graph --decorate --all -15

    4. git show <commit>

      What it doesChecks details, content and edits (diff) for a specific commit or tag

      When to use itto see exactly what was changed at a version or point in time

      Examplegit show v1.0.0

    5. git diff HEAD

      What it doesCompares the entire Working Tree with the last commit in HEAD

      When to use itto see all remaining changes compared to the last commit

      Examplegit diff HEAD

    6. git diff --check

      What it doesDetects whitespace and trailing line errors before committing

      When to use itto avoid unintentional formatting errors in reviews

      Examplegit diff --check

    7. git blame <file>

      What it doesidentifies the last commit and person who changed each line in the file

      When to use itto know the context and date of writing a specific line of code

      Examplegit blame src/server.ts

    Offline · Reading cached copy