Show differences for a specific file or directory
suggest changegit diff myfile.txt
Shows unstaged changes to myfile.txt: the working tree compared with the index. If nothing is staged, that matches the difference from HEAD.
This also works for directories:
git diff documentation
The same comparison for every file under documentation/: unstaged changes only.
To compare the file in a commit with the copy in the working tree:
git diff 27fa75e myfile.txt
Or if you want to see the version between two separate commits:
git diff 27fa75e ada9b57 myfile.txt
To show the difference between the version specified by the hash ada9b57 and the latest commit on the branch my_branchname for only the relative directory called my_changed_directory/ you can do this:
git diff ada9b57 my_branchname my_changed_directory/
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents