What did I do? Read status, log and diff
When to use this: You came back to the project after a while and need to know where things stand and what you changed.
Before you start
Steps
-
Where am I and what is uncommitted?
terminalgit status -sb-sis the short format,-badds the branch line.ahead 2means 2 commits not pushed;behind 1means GitHub has 1 you do not.Expected output
## feature-hero...origin/feature-hero [ahead 2] M src/styles/global.css A src/pages/about.astro
-
What have I committed recently?
terminalgit log --oneline --graph --decorate -n 15One line per commit, newest first.
HEAD -> branchmarks where you are andorigin/mainshows where GitHub is. Pressqto leave the pager.Expected output
* 8c4d7e0 (HEAD -> main, origin/main) Add Vercel domain scenario * 3f2a1b9 Fix broken link on home page
-
What exactly did I change (not staged yet)?
terminalgit diffShows line-by-line edits in your working tree. Lines starting with
-were removed and+were added. -
What is staged and ready to commit?
terminalgit diff --stagedThe same view, but only for what
git addhas staged. -
What did one commit contain?
terminalgit show 8c4d7e0 --statReplace the ID with one from
git log.--statlists files changed; drop it to see the full diff.
How to verify it worked
- You can answer: which branch am I on, what is uncommitted, and what is unpushed.
Common errors and fixes
: or (END) That is the pager. Press q to quit. To avoid it, add --no-pager after git, or run git config --global core.pager cat. git diff shows nothing but status shows changes The changes are staged. Use git diff --staged. Q&A
What do M, A, ?? mean in git status -s?
M modified, A added (new and staged), D deleted, ?? untracked (new and not staged). The left column is the staging area, the right column the working tree.
What does HEAD~2 mean?
Two commits before HEAD. git show HEAD~2 shows that commit.