Commits and history
Write useful messages and inspect what changed.
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.
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| Command | Use it to |
|---|---|
| git diff | See unstaged changes. |
| git log | Review the commit history. |
| git restore | Discard working-tree or staged changes. |
| git revert | Create a new commit that reverses an old one. |
| git reset --soft | Move HEAD back but keep changes staged. |
Your turn
EasyWrite a useful message
Stage login.js and commit with a message that states the user-visible change.
BASH · starter
git add login.jsCheck 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 inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.