Marlo Marlo - 2 months ago 7x
Git Question

origin does not appear to be a git repository

I created a new repository online at github, where i have an account. The project is at, say:

Now I want to add, commit and push things to that project from my file system.
So I opened the terminal on Ubuntu, went to the directory that I want to make into a git folder and typed git init

~/myfolder$ git init

then I typed

~/myfolder$ git clone

then I typed git status, to find that a whole lot of files are untracked. So I added one of them, like

~/myfolder/mysubfolder$ git add subfolderfile.txt

I even committed by

~/myfolder/mysubfolder$ git commit -m "Some comment"

but then pushing it

~/myfolder/mysubfolder$ git push origin master


fatal: 'origin' 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 read other questions on this forum but my level of coding sophistication is that of your average grandma, so I tried

$ git remote set-url origin

but that didn't work: No such remote 'origin'. I am really at a loss.
Please explain in greatgrandpa style what I need to do. Prior knowledge=0. E.g I'd prefer "the big black window" over the Terminal or else I'd be very happy to have a brief explanation of what it is. Thanks so much.


The issue here is almost certainly caused by you running git init first and then cloning your project into the same directory using the git clone command. And even if you can fix the issue by adding the remote to the empty repository that you initialized on your machine, you don't want to do that because you will then have two git repositories, one nested inside the other.

Because of the above, if you don't have any valuable changes in the project on your local machine, it would make things more simple to just blow away all the contents of your ~/myfolder/ dir and re-clone the project by doing the following:

rm -rf ~/myfolder
git clone ~/myfolder

If you have changes that you want to preserve in your project located at ~/myfolder/mysubfolder, then we can just move stuff around to make sure that you don't lose anything. I would recommend first that you do the following to get rid of the nesting:

cd ~/myfolder
rm -rf .git
mv mysubfolder/* .

At this point, you should have all of your project's files and .git folder the mysubfolder/ directory. Which you can check with ls -al

Next we want to check that you have a remote repository properly configured. To do so, run the command git remote -v hopefully you will see the following output:

origin (fetch)
origin (push)

If you don't see the output above, don't have any fear, quick fix. Just run the command:

git remote add origin

At this point we have a reasonable directory structure and the remote repository properly configured for you. Now it's a matter of having access to that remote repository. Since the way you set it up originally was over ssh, the best option, and that's what I've shown you how to do so far, we are going to continue down that path.

First we need to check that you do have a keypair, so do the following:

cd ~/.ssh

If you have a keypair then I would expect to see the two files id_rsa and If you don't have those files (although sometimes they are named differently), then do the following

ssh-keygen -t rsa

Now you should have those files. id_rsa is your private key, which you don't want to leave your computer and should never be shared with anyone, but is you public key, which is a way that other people and services know how to identify you. We need to make sure that your github account has you public key added to it. So now do the following:

  1. login to github
  2. Navigate to
  3. Click the button "New SSH key"
  4. Give it a name like "Home Desktop" or "Work laptop"
  5. Copy the contents of the file
  6. Paste the contents of that file into the key field in github
  7. Click the "Add SSH Key" button

Now you should have no trouble at all push and pulling from your remote repository.