Guide
Make a focused Git commit
A focused Git commit records a coherent change with enough context for another person to understand it.
At a glance
- Inspect state
- git status
- Inspect staged changes
- git diff --cached
Overview
A focused Git commit records a coherent change with enough context for another person to understand it. Review the working tree, stage only the intended changes, and inspect the staged result before recording it so unrelated local work is not accidentally included.
1. Review the working tree
Run git status and inspect the current differences. Identify which files belong to the intended change and preserve unrelated work, including edits that may have been made by another person or process.
2. Stage the intended change
Use git add with explicit paths or an interactive patch workflow to select the intended content. Review git diff --cached because the staged snapshot, rather than every saved file, determines the next commit.
3. Record and inspect
Create the commit with a message that explains the change's purpose. Inspect the resulting commit and working-tree status to confirm which changes were recorded and which remain local.
Sources and review
MOOR's explanatory text is supported by the following source links.
- Recording changes — Pro Git
- git commit reference — Git