About
This page is about text file diff in Git
Syntax
File
- Diff between the head commit of the current branch (HEAD) and the current file not yet committed (in the working area)
git diff HEAD myFile
Branch
Between the head of the main branch and the head commit of the current branch
git diff main..HEAD --summary
# Only deleted / renamed file
git diff main..HEAD --summary | egrep '(delete|rename)'
Other diff tools
diff-index
diff-index 1) is a low level command that checks only file metadata (not the content)
Compare a tree to the working tree or index (staging area)
Example:
git diff-index --diff-filter=AM --name-only HEAD
where:
- diff-filter filters is a sequence of short status
- name-only prints only the name