93
$ git remote add origin [email protected]:lut/EvolutionApp.git
fatal: remote origin already exists.

$ git push -u origin master
fatal: 'EvolutionApp' 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.

My keys were added succesfully

 $ ssh -T [email protected]
 Hi lut! You've successfully authenticated, but GitHub does not provide shell access.

The Github article https://help.github.com/articles/generating-ssh-keys/ says that "Shell access" should not be an issue? What could the problem be?

3
  • What do you see from git remote show origin?
    – SLaks
    Nov 16, 2014 at 2:39
  • 2
    $ git remote show origin fatal: 'EvolutionApp' 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.
    – Lut
    Nov 16, 2014 at 2:52
  • 1
    @SLaks it says is does not appear to be a Git repository, but previously it said that it already exists. I dont get it.
    – Lut
    Nov 16, 2014 at 3:12

8 Answers 8

136

Try and redefine the ssh url for remote origin:

git remote set-url origin [email protected]:lut/EvolutionApp.git

And try again.

Only git remote set-url can change an existing remote URL (as opposed to git remote add, to add a new remote name and URL)
Here, the issue was the URL of the existing remote 'origin', EvolutionApp: it needed to be replaced by a valid one.
Using git config url."ssh://[email protected]/".insteadOf https://github.com/ would not have helped, considering there was no HTTPS URL in the first place.

5
  • 1
    Thanks VonC. This was driving me crazy till I found your post. Godspeed.
    – brohjoe
    Jun 12, 2018 at 0:47
  • Why does github have within their docs that they do not allow shell access? This is confusing. help.github.com/articles/testing-your-ssh-connection
    – brohjoe
    Jun 12, 2018 at 0:49
  • 4
    @brohjoe Because ssh -T [email protected] only gives you a "Welcome" message, not an interactive shell.
    – VonC
    Jun 12, 2018 at 4:49
  • 1
    @MoshtabaDarzi I am sorry it does not work. Could you ask a separate question with more details for me or others to have a look?
    – VonC
    Aug 1, 2020 at 15:53
  • 1
    git pull origin master --allow-unrelated-histories may help.
    – zabala
    May 4, 2022 at 22:28
18

You can add this in the ~/.gitconfig file.

[url "ssh://[email protected]/"]
        insteadOf = https://github.com/

Now ssh will be used instead of https.

2

You might have to add the remote again. That error message happens when Git doesn't know where to push to.

Use git remote -v check if the remote exists, if not, add it.

Even then if it doesn't work try removing the GIT_SSH environment variable, this maybe causing the problem.

2
  • $ git remote -v origin EvolutionApp (fetch) origin EvolutionApp (push)
    – Lut
    Nov 16, 2014 at 2:52
  • Could this message that pops up when Terminal launches be causing the issue? -bash: /etc/profile.d/rvm.sh: No such file or directory
    – Lut
    Nov 16, 2014 at 3:11
1

This can happen if you have an incomplete remote entry in your global config.

Run git config -e --system, comment out any [remote entries, re-add the remote, and try again.

3
  • 1
    $ git config -e --system subl -w: subl: command not found error: There was a problem with the editor 'subl -w'.
    – Lut
    Nov 16, 2014 at 3:33
  • Your git editor is misconfigured. Either install Sublime or configure it to use a different editor.
    – SLaks
    Nov 16, 2014 at 3:36
  • I ran git config --global core.editor "subl -n -w" but still get an error. I can succesfully open Sublime from Terminal with open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl I think I has something to do with my profile. Everytime I open a new terminal window I get -bash: /etc/profile.d/rvm.sh: No such file or directory
    – Lut
    Nov 16, 2014 at 3:51
1

check if you are using https as remote url instead of ssh. I set my remote url to http and encountered this issue. After resetting the url to ssh protocol the problem is gone.

1

I also encountered this problem when moving from one repository to another. I had already used this Git account before in other projects and there was already a ssh key there that was successfully used by other servers. But it was impossible to upload the key from my new server. I had to make a new key and upload a second one to the repository. Old key I tried upload git has ignored it whithout any error messages.

#rename old repository
git remote rename origin origin_old

#adding new address of repository
git remote add origin [email protected]:you_mail/your_project.git

#creating new ssh key
ssh-keygen -t ed25519 -C "[email protected]"

eval `ssh-agent`
ssh-add ~/.ssh/id_ed25519

Now, upload id_ed25519.pub to git. Check presence of this file in your account!

git remote set-url origin [email protected]:you_mail/your_project.git
git push -u origin master
git remote set-head origin master
0

if there is trust issue for android studio or vs code project in git You can give safe permissions like below , with your project path in Ubuntu

git config --global --add safe.directory '_your_project_path'

git config --global --add safe.directory '/data/project/project/MyApp/android_app'

0

I ran into this error while trying to clone a repo on Cent OS 8.

I had to use https instead of ssh to clone and it successfully worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.