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)
GitHub has now introduced a feature to sync a fork with the click of a button. Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.
If you want a local branch, use the --track option. "git fetch" to make sure your repo is updated with remote references and "git checkout --track origin/discover" should be enough. Then you can commit to that branch and a "git push" to sync the remote with your changes.
The easiest way to set the upstream branch is to use the “git push” command with the “-u” option for upstream branch. Alternatively, you can use the “–set-upstream” option that is equivalent to the “-u” option. As an example, let's say that you created a branch named “branch” using the checkout command.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With