Always in a repository you have a hidden branch, which you can see by using git branch -a.
That hidden branch is origin/master.
You, by using git fetch, push the changes from the remote repository to the branch origin/master:
git fetch origin
Now you have the changes in origin/master, but you would have to pass them to the branch master, for that you have to use:
git merge origin/master
From this you have the new changes in your branch masterand that's it.
Here's an image I made to explain this part:
When using git pullthese combining git fetch+ git merge.
git pull origin master
In conclusion git pull, you are saving yourself from using one more command, but I recommend that if you are just starting to use git, continue using git fetchandgit merge
It actually git pullpulls changes from the given branch and updates it against your local repository.
git fetchpulls down the changes from the given branch and puts it in a mirror branch which is just a kind of hidden branch where you can look at the changes from that branch, and then merge with your local branch.
He git pullis just a git fecth + git merge. Don't use git pullif you're really in doubt as to what changes can be brought in from the remote repository.
When you do a git fetch, the changes from your remote repository (if any) will be downloaded to a folder called origin/master , which is a hidden folder. To include the changes to your local branch you need to merge master with origin/master.
Very briefly: with fetch you only query the changes that are in the repository with respect to your local copy; and with pull you download the changes to your local. I think that Sourcetree does a fetch before doing a pull.
From the documentation :
or doing a free translation:
That is, it
git fetch
checks in the changes, but leaves them in another branch , until the checkout is donegit merge
to the local branch .Always in a repository you have a hidden branch, which you can see by using
git branch -a
.That hidden branch is
origin/master
.You, by using
git fetch
, push the changes from the remote repository to the branchorigin/master
:Now you have the changes in
origin/master
, but you would have to pass them to the branchmaster
, for that you have to use:From this you have the new changes in your branch
master
and that's it.Here's an image I made to explain this part:
When using
git pull
these combininggit fetch
+git merge
.In conclusion
git pull
, you are saving yourself from using one more command, but I recommend that if you are just starting to use git, continue usinggit fetch
andgit merge
It actually
git pull
pulls changes from the given branch and updates it against your local repository.git fetch
pulls down the changes from the given branch and puts it in a mirror branch which is just a kind of hidden branch where you can look at the changes from that branch, and then merge with your local branch.He
git pull
is just agit fecth + git merge
. Don't usegit pull
if you're really in doubt as to what changes can be brought in from the remote repository.When you do a
git fetch
, the changes from your remote repository (if any) will be downloaded to a folder called origin/master , which is a hidden folder. To include the changes to your local branch you need to merge master with origin/master.Git pull
it does all that automatically.Very briefly: with fetch you only query the changes that are in the repository with respect to your local copy; and with pull you download the changes to your local. I think that Sourcetree does a fetch before doing a pull.