Reading diffs and logs
Use status, diff and log to see what changed, what is staged and how your history is shaped.
- Check which files changed with git status
- Read unstaged and staged changes with git diff
- View a compact picture of history with git log
- Inspect the details of a single commit
In plain English
Git stores your work in two places before it is committed: the working tree, which is the files you can see and edit, and the staging area, which holds the exact changes you have chosen for the next snapshot. A diff is the list of lines that were added, removed or changed between two versions of a file. A log is the ordered list of commits in your repository, and each commit is one saved snapshot with a message. Reading these views tells you what changed, why, and where you are in the project history.
Step by step
- 1Run git status to see which files have changed and whether they are staged.
- 2Run git diff to read the exact lines that changed in the working tree.
- 3Run git diff --staged to review what is ready for the next commit.
- 4Run git log --oneline --graph to see a compact picture of your history.
git status
git diff
git diff --staged
git log --oneline --graph
git log -p
git show HEADCommon mistakes
- Running git diff --staged and expecting to see brand-new untracked files, which Git only shows once they are added.
- Trusting your memory of what changed instead of reading git diff before committing.
- Confusing git diff, which shows unstaged changes, with git diff --staged, which shows changes ready to commit.
- Treating git log as the place to see uncommitted edits, when it only shows saved history.
Read the latest commit
Show a compact, graphical view of your history, then display the details of the most recent commit.
What does git diff --staged show?
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Lock in what you just learned.
Mark this lesson complete to save your place and move one step closer to the certificate.