Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Fetch vs Pull: Different Results, Not Sure Why

Tags:

git

I usually do a git fetch origin followed by a git merge remotes/origin/master, but was getting a Already up-to-date response. I knew this wasn't true. A git pull origin worked fine and brought in the changes.

What did I do wrong?

like image 642
swt83 Avatar asked Nov 13 '22 07:11

swt83


1 Answers

When you did:

$ git fetch origin

you were not getting the origin/master branch. Assume you were getting origin/other. Then when you did:

$ git merge remotes/origin/master

because there was nothing new on origin/master (you never fetched it) there was nothing to merge. You got 'already up-to-date'. As you know, when you did:

$ git pull origin

there was a merge to perform because 'pull' did a fetch (of origin/other) and then a merge (of origin/other). You should be able to see which branches are configured for 'pull' and 'push' with

$ git remote show origin

Fix it with:

$ git checkout master
$ git branch --track master origin/master
like image 147
GoZoner Avatar answered Nov 16 '22 00:11

GoZoner