log and diff
What this is. Two commands read history from different angles.
git log shows the commits: what was recorded, by whom, and why.
git diff shows the changes: which lines actually differ.
Log answers what has happened. Diff answers what is different right now.
Useful forms of log.
git log gives the full entries.
git log --oneline gives one compact line per commit, which is what you want most of the time.
A history you can skim in --oneline form is a history with good commit messages. If yours is unreadable that way, the messages are the problem, not the tool.
✦ Run diff before you stage, every time
git diff shows what you changed but have not yet staged. Reading it before git add is how you catch the debugging line you meant to remove, the file you edited by accident, and the change you no longer want. It takes seconds and it is the single most effective habit for keeping a history clean.
Mark this lesson complete
Signed in, your progress follows you to every device.