12

I'm trying to use git fetch upstream master to get the latest commit from another user's repository. But unfortunately that doesn't work. I have also tried git fetch upstream.

What does work is git pull upstream master, but I don't want to use that all the time, because that will always automatically perform a merge.

This is the output that I get when I execute git fetch upstream master:

git fetch upstream master
From https://github.com/jchun/nodeSite
 * branch            master     -> FETCH_HEAD

And here are my remotes:

git remote -v
origin git@github.com:superzaky/nodeSite.git (fetch)
origin git@github.com:superzaky/nodeSite.git (push)
upstream       https://github.com/jchun/nodeSite.git (fetch)
upstream       https://github.com/jchun/nodeSite.git (push)
superkytoz
  • 1,153
  • 2
  • 21
  • 41

1 Answers1

17

The fetch did work, but to see the result, you should do a:

git log --oneline --all --graph --decorate --branches

You would see the upstream branches (including the upstream/master)

You can also check the latest SHA1 fetched with:

git branch -avv

The git pull upstream master didn't repeat the fetch part (since it was already done), but merge as well upstream/master to master.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 3
    Ah yes your first command did work, the second command didn't work unfortunately. Here is a screenshot of it link: http://i.imgur.com/EejCCF5.png I still got a question: the fetch did work, but how can I now update my repository with the latest commits from the user's repository? – superkytoz May 03 '15 at 18:41
  • @superkytoz yes, it was `git branch` (I have it aliased to `git br`). In order to update your fork, see http://stackoverflow.com/a/3903835/6309: you `git rebase upstream/master` your own master branch, and then push to your fork. – VonC May 03 '15 at 18:43
  • Why doesn't `git log --pretty=oneline` show the upstream commits? – IgorGanapolsky Dec 27 '15 at 22:53
  • 1
    @IgorGanapolsky upstream means you need the `--all` option – VonC Dec 28 '15 at 07:43