Sikau

Git & GitHub · Day 3 · about 25 min

Reading history

log, show and diff: what changed, when and why.

Who changed the price?

Yesterday momos cost Rs 150. Today the page says Rs 15. History tells you exactly which commit changed it, when, and the message that explains why.

Looking back

git log --oneline
git show HEAD
echo "Momo: Rs 180" > menu.txt
git diff
git add menu.txt
git diff --staged
  • git log (full details), git log --oneline (compact), git log -3 (last three).
  • HEAD~1 means "one commit before HEAD"; HEAD~2 two before.
  • git diff HEAD~1 HEAD compares two commits.

The rest of this lesson

  • Reading a diffexplain
  • Finding when something changedexplain
  • Read the diffpredict
  • HEAD~2predict
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 18 lessons of Git & GitHub