How to show uncommitted changes in Git and some Git diffs in detail
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Inspecting uncommitted changes is the fastest way to prevent accidental regressions before a commit. Git provides lightweight summaries and deep diff tools for both staged and unstaged edits. A repeatable review sequence helps you catch missing files, noisy formatting changes, and incorrect logic early.
Start with a Clean Overview
Run status first so you know what category each file belongs to.
The short format gives a compact view of modified, added, deleted, and untracked paths. After that, check the size and distribution of changes.
--stat is human-friendly, while --numstat is useful for scripts and CI hooks.
Inspect Unstaged and Staged Diffs Separately
Unstaged and staged diffs are different working sets. Review both every time.
For better readability in long lines, word-level mode helps highlight exact token changes.
If whitespace noise is distracting, ignore it temporarily, then recheck without ignore before committing.
Ignoring whitespace can hide real indentation-sensitive changes in languages such as Python, so use it only as a secondary view.
Focus on Specific Files or Hunks
When a commit touches many files, path-scoped diffs keep review manageable.
You can also compare your work tree file directly against a known commit.
For larger refactors, a function-context view often shows intent better.
This includes surrounding function blocks, which is useful when logic spans many small line changes.
Review Rename and Mode Changes
Some risky edits are not obvious in default diff output. Include metadata checks.
This reveals renames, permission mode changes, and file type transitions. In deployment scripts and executables, mode changes are especially important.
Build a Personal Pre-Commit Checklist
A practical sequence that works well in most repos is:
--check highlights whitespace errors and conflict markers in staged content. Add this sequence to an alias or shell function to make it habitual.
Then run git review before every commit.
Compare Against Merge Base for Review Prep
Before opening a pull request, inspect differences from the merge base rather than only from local HEAD. This view reflects what reviewers will see once your branch is compared with the target branch.
Using this check reduces surprises caused by rebases or stale local assumptions about branch history.
Common Pitfalls
- Reviewing only unstaged changes and forgetting staged changes.
- Relying on
-woutput and missing indentation-sensitive bugs. - Skipping rename and mode checks for deploy scripts or executable files.
- Committing debug logs or temporary files because status was not reviewed first.
- Using huge commits that make diffs too noisy to evaluate accurately.
Summary
- Start with
git status -sbto classify file states quickly. - Use
git diffandgit diff --cachedas separate mandatory reviews. - Add focused views such as
--word-diff, path filters, and function context. - Include
--summaryand--checkto catch metadata and whitespace problems. - Standardize your review sequence with an alias to reduce human error.
Related reading
- How to shrink the .git folder
- How to solve Permission denied publickey error when using Git?
- How to sort in-place using the merge sort algorithm?
- How to sparsely checkout only one single file from a git repository?
- How to specify the private SSH-key to use when executing shell command on Git?
- How to squash all commits on branch
- How to squash all commits on branch
- How to squash all git commits into one?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseInterview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.