Reputation: 839
I need to diff two objects in git. One is a tree (directory) in my working directory, and the other one is a remote branch. I can do so if I find the SHA of the tree and use that in the argument of my git diff command along with the remote branch. However, I am trying to find a way not to have to dig in the SHA first.
So, for example, if:
My_Working_Dir
file1
file2
Dir1
file3
file4
remote_branch/master
file3
file4
Then I like to be able to issue something like this:
git diff Dir1 remote_branch/master
This works if I replace Dir1 with its SHA, but not if I just try to use the directory name. I have tried to use diff-tree as well. But that is not helping either. Please note that the remote_branch/master does not have the Dir1 directory.
Any help is appreciated.
Thanks in advance.
Upvotes: 0
Views: 1486
Reputation: 4169
You can use <branch>:<file_path>
notation with git diff
git diff remote_branch/master:file3 HEAD:Dir1/file3
git diff remote_branch/master:file4 HEAD:Dir1/file4
Upvotes: 2
Reputation: 12837
You can simply use the path argument after the --
.
I.e.
git diff remote_branch/master -- Dir1
Upvotes: 1