1

I have a project which uses Git on a remote server. I installed SourceTree for Mac to manage it. I also have a .ssh folder with the private in the root directory where I keep all my projects and the public key is in the server.

I was able to clone the project successfully and even commit+push it back with no problem. Then I ceated a branch in my local repo, added a new file and tried commit+push it. It was committed but the pushing failed with the following error message.

Pushing to git@gitserver:gitbtest

ssh: Could not resolve hostname gitserver: nodename nor servname provided, or not known

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I'm not sure why this is happening. Is there a way to set SSH keys in SourceTree for Mac? I can't seem to find any option to do so.

Any help to resolve this would be great.

Thank you!

Isuru
  • 30,617
  • 60
  • 187
  • 303
  • Did you change anything between the time you successfully pushed from your repo/master and the time you are pushing from your branch? – VonC Jul 21 '14 at 06:13
  • After testing pushing from the master, I just created a branch, added a new file to it and tried pushing it to the server. That's when this problem occurred. – Isuru Jul 21 '14 at 06:28
  • do you have a `$HOME/.ssh/config` file? – VonC Jul 21 '14 at 06:35
  • No, I only have these 3 files in the .ssh folder. id_rsa, id_rsa.pub, known_hosts – Isuru Jul 21 '14 at 06:40

1 Answers1

3

An url like git@gitserver:gitbtest can only work if one have an ssh config file in order to resolve the name gitserver:

$HOME/.ssh/config

Host gitserver
   Hostname xxx.xxx.xxx.xxx # IP or full name for gitserver
   User git
   IdentityFile ~/.ssh/id_rsa

Actually, with such a file, you don't even have to specify the user:

git remote set-url origin gitserver:gitbtest

(You can see an example of that ~/.ssh/config file used in "git public key for more repositories")

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250