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:

https://github.com/myname/myproject

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 git@github.com:myname/myproject.git

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

gives

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 git@github.com:myname/myproject.git

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.

  • Git error: src refspec master does not match any
  • Gerrit and repo
  • Accessing files of a repository from the Git server
  • Understanding Meld 3 way merge with Git
  • What is the best way to share some personal test code between repositories by CocoaPods podspec dependency?
  • Is it possible/reasonable to have multiple online repositories for a single project?
  • How to add old zipped sources at the beggining of origin trunk?
  • How to add the changes made in home directory to my existing repository in github
  • 2 Solutions collect form web for “origin does not appear to be a git repository”

    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 git@github.com:myname/myproject.git ~/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  git@github.com:myname/myproject.git (fetch)
    origin  git@github.com:myname/myproject.git (push)
    

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

    git remote add origin git@github.com:myname/myproject.git
    

    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
    ls
    

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

    ssh-keygen -t rsa
    ls
    

    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 id_rsa.pub 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 id_rsa.pub added to it. So now do the following:

    1. login to github
    2. Navigate to https://github.com/settings/keys
    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 id_rsa.pub
    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.

    Try using https://github.com/myname/myproject.

    If this doesn’t work, make sure you are signed in to the Git account you used to create the online repo. git config --global your.name and git config --global your.email should do the job.
    I hope this helps!

    EDIT: Are you using a branch of Debian? E.G. Raspbian, Ubuntu, etc.
    If so, you should be able to run sudo apt-get install git-gui. After that, in your desktop, you should have a new app that says something like “Git”. Open that and you should have a graphical interface, if you prefer that 😉

    Git Baby is a git and github fan, let's start git clone.