git-diff
Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk.
git diff --stat
app/a.txt | 2 +-
app/b.txt | 8 ++----
2 files changed, 10 insertions(+), 84 deletions(-)
git diff --name-status
M src/app.py
A src/new_file.py
D docs/old.md
Where:
- A = Added
- M = Modified
- D = Deleted
- R = Renamed
For staged changes:
git diff --cached --name-status
Then compare your branch with the remote:
git diff --name-status origin/main..HEAD
Exit with a status (useful for scripts)
If you just want to know whether anything has changed in specific directories:
git diff --quiet -- src/ docs/
Then check the exit code:
- 0 → no changes
- 1 → changes exist
For staged changes:
git diff --cached --quiet -- src/ docs/