Search code examples
gitgit-fetch

git fetch does not update my local branch


I am new to git (have used other version control systems like Perforce) but what I am trying to do seems very basic to do it wrong.

I have a local workspace and a remote one. I want to bring changes from the remote to local (not force update but merge them with my local workspace).

If I do this :

git diff master remote_name/master

I can see there are a lot of differences.

So, I am trying to fetch stuff from remote :

Tried both :

git fetch remote_server
git fetch remote_server master

where remote_server is the name I have given (I see this if I run git remote -v )

But my local files do not change.

What am I missing?


Solution

  • git fetch only does just that - fetches the commits from the remote server into your local copy of the remote branches (see git branch -a for a list).

    What you probably want is git pull, or to do (on master)

    git fetch remote_server
    git merge remotes/origin/master
    

    git pull (roughly speaking) just combines those two.