'Differences between git pull origin master & git pull origin/master
What is the difference between git pull origin master
and git pull origin/master
?
Solution 1:[1]
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".
Solution 2:[2]
git pull origin master
will fetch all the changes from the remote's master branch and will merge it into your local. We generally do not 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:
fatal: 'origin/master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | questionto42standswithUkraine |
Solution 3 | user33276346 |