I\'m very new to Git, so facing some issues with it correct usage. Here is my scenario.
I have a fork of my master repository and cloned it into my local. In that, I hav
The article you link to (though it may have changed since you asked) starts with a reference to https://help.github.com/articles/configuring-a-remote-for-a-fork/. If you complete this you will have a new remote repository named upstream pointing to the original repository which you forked, and git fetch upstream
will work.
Just run the following command on your terminal
$ git remote and upstream {your upstream repository link here}
After this command run :
git remote -v
this command will show you your github repository path and upstream repository path .
example output:
origin https://github.com/ {Your Github username} / {repository name} (fetch)
origin https://github.com/ {Your Github username} / {repository name} (push)
upstream https://github.com/ {Upstream github username} / {repository name} (fetch)
upstream https://github.com/ {Upstream github username} / {repository name} (push)
The steps below will enable you to link your git fork and the original repository so that you can pull changes from the original repository anytime it's updated. Go to the repository's page on github and click on fork (if you haven't done so already). Assuming you forked a repo called repo-name from https://github.com/account/repo-name then you get a copy (fork) of the repo on your own account under something like https://github.com/your-user-name/repo-name Then run the commands below on your terminal
git clone https://github.com/your-user-name/repo-name.git
cd repo-name
git remote add upstream https://github.com/account/repo-name.git
git pull upstream master
git branch --set-up-stream-to=upstream/master
git pull
When you make changes and wish to integrate it the original codebase, in order to add your changes to the original repo, you have to push to your fork first on github and send a pull request which will then be verified and merged to the codebase. Steps below.
git add .
git commit -m "commit message"
git push origin master
Then visit your account on github and click on your repo-name. On the page, you'll see a link to create pull request. Click on the link and create pull request which will then be reviewed and merged by the maintainer.
You must get a fork of a git project then:
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git,
you can proceed git fetch upstream
So there's a few things to clarify:
Upstream is the conceptual name of the remote repository (or repositories) that exist. Most projects only have one upstream repository.
The name of the upstream repository can vary from project to project, but by convention is origin.
That said, I'm willing to bet that you got the name of your upstream repo and the upstream repo concept confused, and you should be executing git fetch origin
. Verify with git remote
; use the appropriate name from that list.
However, if you only have one upstream repo, performing git fetch
will accomplish the same thing.