- It is used to show changes between commits, commit, and working tree, etc.
- Mostly helpful when merge conflict to identify changes made by commits
1 | Track the changes of two commits | git diff <commit1-sha> <commit2-sha> |
2 | Track the changes of two branches | git diff <branch 1> < branch 2> |
3 | Track the changes of latest commit (* Not confirmed) | git diff HEAD |
4 | Track the changes of staged files | git diff –staged |
5 | Track the changes of unstaged files (* Not confirmed) | git diff |
4 | Track the changes made of a single file | git log -p –follow — filename |
(i) Checking the diff of two commits :
git diff <commit1-sha> <commit2-sha> |
(ii) Track the changes of two branches :
git diff <branch-1> <branch-2> |
(iii) Checking the diff of staged files :
git diff –staged |