git difference between origin/master and origin master

时间:2018-02-03 09:53:39

标签: git

I seem to have a weird difference in origin/master

The commands are run in order

I am on the master branch and ran the commands in sequence

git pull origin master

Same output:

git diff origin/master 
git diff remotes/origin/master

Different output:

git diff origin/master
git diff origin master

Can someone explain why is this so?

Thanks.

1 个答案:

答案 0 :(得分:1)

When you have use origin, it itself means origin/master i.e. your master branch on remote server. For specifying some other branch on remote server, you will need branch name. E.g origin/mybranch123.

And When you type master (or any other branch name) alone, without origin you are referring to local branch.

Now correct way to see the diff is git diff branch_name1 branch_name2

So you see the actual result when you are typing the last command. In typing git difforigin/master you are just specificying 1 branch name. Same is the case with remotes/origin/master as it is same as origin/master.