Differences between git pull origin master & git pull origin/master

前端 未结 3 1524
花落未央
花落未央 2020-12-04 04:39

What is the difference between git pull origin master and git pull origin/master ?

相关标签:
3条回答
  • 2020-12-04 04:51

    git pull origin master will fetch all the changes from the remote's master branch and will merge it into your local.We generally don't use git pull origin/master.We can do the same thing by git merge origin/master.It will merge all the changes from "cached copy" of origin's master branch into your local branch.In my case git pull origin/master is throwing the error.

    0 讨论(0)
  • 2020-12-04 05:01

    git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch.

    git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch. The origin/master branch is essentially a "cached copy" of what was last pulled from origin, which is why it's called a remote branch in git parlance. This might be somewhat confusing.

    You can see what branches are available with git branch and git branch -r to see the "remote branches".

    0 讨论(0)
  • 2020-12-04 05:07

    git pull = git fetch + git merge origin/branch

    git pull and git pull origin branch only differ in that the latter will only "update" origin/branch and not all origin/* as git pull does.

    git pull origin/branch will just not work because it's trying to do a git fetch origin/branch which is invalid.

    Question related: git fetch + git merge origin/master vs git pull origin/master

    0 讨论(0)
提交回复
热议问题