git: diff between file in local repo and origin

后端 未结 7 2152
我在风中等你
我在风中等你 2020-12-04 04:42

I want to find the differences between a file I have in my local repo vs what is in the origin master.

I know that there is git diff, howev

7条回答
  •  忘掉有多难
    2020-12-04 05:21

    To view the differences going from the remote file to the local file:

    git diff remotename/branchname:remote/path/file1.txt local/path/file1.txt
    

    To view the differences in the other direction:

    git diff HEAD:local/path/file1.txt remotename/branchname:remote/path/file1.txt
    

    Basically you can diff any two files anywhere using this notation:

    git diff ref1:path/to/file1 ref2:path/to/file2
    

    As usual, ref1 and ref2 could be branch names, remotename/branchname, commit SHAs, etc.

提交回复
热议问题