Git & GitHub·Version control

Commits and history

Write useful messages and inspect what changed.

Beginner 12 min read Lesson 2 of 480 Challenge included
What you will be able to do
  • Write a conventional commit message
  • Read a diff
  • Undo a mistake safely

History is a tool for future you. A good commit message explains why a change exists, not just what files changed.

terminalTerminal
git diff
git diff --staged
git log --oneline --graph --all

# undo unstaged changes to one file
git restore index.html

# unstage, but keep the edits
git restore --staged index.html
CommandUse it to
git diffSee unstaged changes.
git logReview the commit history.
git restoreDiscard working-tree or staged changes.
git revertCreate a new commit that reverses an old one.
git reset --softMove HEAD back but keep changes staged.
Your turn

Write a useful message

Easy

Stage login.js and commit with a message that states the user-visible change.

BASH · starter
git add login.js
Check your understanding before moving on.
Knowledge checkQuestion 1

Which command safely undoes a pushed commit?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 2 of 480 · 0% of course