16

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 [email protected]:superzaky/nodeSite.git (fetch)
origin [email protected]:superzaky/nodeSite.git (push)
upstream       https://github.com/jchun/nodeSite.git (fetch)
upstream       https://github.com/jchun/nodeSite.git (push)

1 Answer 1

20

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Ah yes your first command did work, the second command didn't work unfortunately. Here is a screenshot of it link: 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 yes, it was git branch (I have it aliased to git br). In order to update your fork, see stackoverflow.com/a/3903835/6309: you git rebase upstream/master your own master branch, and then push to your fork.
Why doesn't git log --pretty=oneline show the upstream commits?
@IgorGanapolsky upstream means you need the --all option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.