0

I can’t push to GitHub through the Mac terminal in Eclipse - I found a question about the same problem, but can’t use the answer.

The answer I found: Git does not use SSH key for Github (Mac OS)

But when I try to use the answer, replacing the GitHub account name and the repo name with mine, I get:

[email protected]:alexandranes/demo-repo.git
ssh: Could not resolve hostname github.com:alexandranes/demo-repo.git: nodename nor servname provided, or not known

What can be the problem?

Thank you very much in advance for help!

11
  • Does the command ssh -T [email protected] provided in the other answer give the same error? Commented Jun 29 at 10:27
  • @abrain Yes, it does. Commented Jun 29 at 10:31
  • This seems to be a private repo. Are you sure your ssh keys are properly set and you are running the IDE terminal with the right OS user? Commented Jun 29 at 11:09
  • @LajosArpad No, it says 'public' repo on GitHub. Yes, the right OS user. No, not totally sure that ssh keys are properly set. Although, I followed the tutorial and got the 'identity added' message in the terminal. How can I check? Also, I cloned through the IDE GUI but am trying to push through the IDE terminal. Could this have caused the problem? Thank you! Commented Jun 29 at 11:33
  • The only repo I do see on your GitHub is github.com/alexandranesterova/alexandranesterova which is not demo-repo . So demo-repo either does not exist or is private. Commented Jun 29 at 11:57

1 Answer 1

0

Based on the error message Could not resolve hostname github.com:alexandranes/demo-repo.git it appears that the entire URL is used as hostname, which then cannot be resolved. As seen in this example, only the part before the colon should appear in the error message.

% git clone test.invalid:foo/bar.git                         
Cloning into 'bar'...
ssh: Could not resolve hostname test.invalid: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Is it possible that the : is a lookalike character? Try and copy the SSH URL from the GitHub repository page (under the green Code button) just to be sure.

Here are some additional things to try:

Check remotes

You mentioned that you cannot push, which indicates that the repository is already cloned. Execute the command git remote -v to check if the remote URLs are set correctly. The result should look like this

origin  [email protected]:alexandranes/demo-repo.git (fetch)
origin  [email protected]:alexandranes/demo-repo.git (push) 

If the result looks different, you can set the correct URL with

git remote set-url origin [email protected]:alexandranes/demo-repo.git

Try cloning again

If you haven's cloned the repository yet, or just to test again with a fresh one, you can try and clone it again somewhere else (e.g. ~/Downloads or /tmp).

To be sure, try and use the macOS Terminal instead of the Eclipse terminal.

git clone [email protected]:alexandranes/demo-repo.git
Sign up to request clarification or add additional context in comments.

2 Comments

SSH URL from GitHub gives the same result for some reason. The remotes are correct. I'll try to clone again; I originally cloned through the IDE GUI but am trying to push through the IDE terminal. Thank you!
What was the full command you invoked?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.