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.
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 clean
git pull# get last commits from remote repo
git checkout <your-branch># switch back to your side branch
git merge master# merge the master commits into your-branch
git push origin <your-branch># to backup your commits/updates in remote repo
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
Also, the question is already answered here: http://stackoverflow.com/questions/292357/difference-between-git-pull-and-git-fetch
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 merge origin\master
I would recommend going through this quick tutorial: https://try.github.io/