How can I inspect exactly what changed in a particular Git commit?
Quick answer
Run git show <commit> to see the chosen commit’s message and textual diff. For a compact path summary, use git show --stat --name-status <commit>. These show the commit’s recorded changes, not necessarily the files’ current contents. Use git diff <commit> to compare that commit with the working tree, or name two commits to compare them with each other. [S1] [S2]
The question, the details, the next step.
A practical checklist
Choose the commit identifier you want to inspect.
Run
git show <commit>for its message and textual diff.Use
git show --stat --name-status <commit>for a changed-path summary.Use
git diff <commit>for a working-tree comparison, orgit diff <first-commit> <second-commit>to compare two commits.For a merge commit, remember that
git showuses a combined-diff format by default. [S1]
A few more useful answers
Does `git show <commit>` tell me what is in the working tree now?
Does `git diff <first-commit> <second-commit>` list all commits between them?
No. It compares the two specified commits; it does not list a commit range. [S2]
Why might a merge commit’s `git show` output look different?
By default, Git displays a merge commit using a combined-diff format, which may be interpreted differently from an ordinary single-parent commit. [S1]
Sources
References used for this guide.
- [S1] Git git-show documentation git-scm.com · Checked
- [S2] Git git-diff documentation git-scm.com · Checked
