Reputation: 323
I've been reading about git pull
and git fetch
, I'm getting a little confused now. So on the master branch, there have been commits made since I've last done work. If I want to update my local repository to continue working, am I supposed to pull the commits from the master branch to my own branch? I tried to do a git fetch
from my own branch to update it. But from what I read, this doesn't completely update my local repository and that I would need to merge.
Upvotes: 2
Views: 6199
Reputation: 11367
git pull
is actually a combination of: git fetch
& git merge
. You probably what to do the following:
git checkout master
# switch to master branch on your local repo.git status
# make sure you are cleangit pull
# get last commits from remote repogit checkout <your-branch>
# switch back to your side branchgit merge master
# merge the master commits into your-branchgit push origin <your-branch>
# to backup your commits/updates in remote repoUpvotes: 1
Reputation: 1452
git fetch
will download all the repository information from your remote
. This stores it in the remote (try running git remote show
). So now you will have a branch called origin\master
. You can see your branches on your remote by running git branch -a
origin\master
is different from master
so you will need to git merge origin\master
to syncronize with your remote origin.
git pull
automatically runs several commands
git fetch
git merge origin\master
I would recommend going through this quick tutorial: https://try.github.io/
Upvotes: 0
Reputation: 183
git fetch
only downloads patch files from a remote repository, but does not apply them. In simple terms git pull
is a short-hand for git fetch; git merge;
.
To update your files git fetch
is not sufficient - make a git pull
Also, the question is already answered here: https://stackoverflow.com/questions/292357/difference-between-git-pull-and-git-fetch
Upvotes: 1