Git Log & Diff

View history and changes.

✍️ 2 exercises in this lesson
  • git log: full commit history.
  • git log --oneline --graph: a compact view with branches.
  • git diff: unstaged changes.
  • git diff --staged: changes that will go into the next commit.
  • git show <commit>: details of one commit.

Key Takeaways: Git Log & Diff

Mastering Git Log & Diff helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Git Log & Diff Code Example

Git
git log --oneline
echo "<p>Welcome</p>" >> index.html
git diff
Output
8c4d7e2 (HEAD -> main) Add homepage
3f2a1b9 Add README
diff --git a/index.html b/index.html
@@ -1 +1,2 @@
 <h1>Home</h1>
+<p>Welcome</p>
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

Git Log & Diff Practice Exercises

Check what you learned in “Git Log & Diff”.

/ 2 solved
Fill in the blank

Show the history in a compact form.

git log 
✓ Correct! Not quite. Try again.
Multiple choice

Which command shows changes that are staged for the next commit?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services