Git Error : 'upstream' does not appear to be a git repository
GitGithubGit Problem Overview
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 have 2 branches for different fixes.
When I commit, I saw a statement in the git-we saying that I'm 3 commits ahead and around 20 commits behind.
I understand that my fork is not in sync with master. Also I need to merge the two branches too (or should i do it?)
I used the windows client to syncing. But seems I'm not following the Git way. So, I tried to follow the steps described in https://help.github.com/articles/syncing-a-fork/ which is giving me an error as follows (I'm using windows).
$>git fetch upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm a bit confused. Please help me with steps I should follow in this scenario.
@HuStmpHrrr
Sorry for adding the details in comments I'll modify the question for readability
By executing the command:
$>git remote returning two values
acme-development (which the name of my actual/main repository, from where I forked) and
origin
Adding some more info.
After making a fetch, I tried a origin/master merge on to my master Please see the screenshot
But, if I login to my Github online account, it is saying a different story.
My git client says that the local repo is up to date. But the online git says that we are 42 commits behind and 7 commits ahead.
Git Solutions
Solution 1 - Git
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.
Solution 2 - Git
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.
Solution 3 - Git
Here are the steps I followed today to solve that same problem
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.
Solution 4 - Git
Just run the following command on your terminal
$ git remote add 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)
Solution 5 - Git
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