1

I followed instructions here to the letter https://docs.github.com/en/authentication/connecting-to-github-with-ssh

I run the following (my username entered at <myname> )

git remote add origin git@github.com:<myname>/aws-bootstrap.git

I then get fatal: remote origin already exists.

Then I run git push -u origin master

ssh: Could not resolve hostname github: 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.

Any ideas what could be wrong?

  • "*Could not resolve hostname **github***" `github` must be `github.com` – phd Feb 19 '22 at 14:43
  • 3
    Well, it looks like you already have a remote named `origin`, but it seems to have been configured with a bad hostname (`github` instead of `github.com`). You could remove the remote (`git remote rm origin`) and then re-add it using the commands you've shown in your question, or you could fix it with `git remote set-url origin ...`. – larsks Feb 19 '22 at 14:44

1 Answers1

3

The error could be caused by a number of things, as others have mentioned though, its likely that your origin remote is configured incorrectly. If so, this thread has some useful context:

git - remote add origin vs remote set-url origin

I find sometimes it can be easier to manually inspect/edit the <project dir>/.git/config file as well incase a typo was made somewhere.

Regarding the access rights message

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

if your <project dir>/.git/config looks good, make sure your SSH private/public key are configured correctly both locally and on GitHub.

It may be helpful to print both SSH and git logs if neither of those suggestions resolve the problem:

$ GIT_SSH_COMMAND="ssh -vvv" $GIT_TRACE=1 git push -u origin master
deric4
  • 1,095
  • 7
  • 11