origin does not appear to be a git repository
- How to Do a Complicated Git Repository Merger?
- What is the git equivalent for a specific version checkout, like “svn checkout -r 123 <svn_rep_url>”
- wrong git repo owner
- Local repository with Git
- Git mirror repository using two remotes
- Moving a git repository down a hierarchy level
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 firstname.lastname@example.org: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
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 email@example.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.
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 firstname.lastname@example.org: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
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 email@example.com:myname/myproject.git (fetch) origin firstname.lastname@example.org: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 email@example.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.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:
- login to github
- Navigate to https://github.com/settings/keys
- Click the button “New SSH key”
- Give it a name like “Home Desktop” or “Work laptop”
- Copy the contents of the file
- Paste the contents of that file into the key field in github
- Click the “Add SSH Key” button
Now you should have no trouble at all push and pulling from your remote repository.
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 😉