SSH local to github confusion

Issue

I’m a total beginner trying my first local to Github. I’ve properly set up my SSH to work with Github. I can do a

ssh -T git@github.com

and get the success message. However, when I try to initially move my local files to my new Github repo,

git remote add origin git@github.com/mygithub/myrepo.git
git push -u origin master

I get

fatal: 'git@github.com/mygithub/omni.git' 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 try the standard

git remote add origin https://github.com/mygithub/myrepo.git

it seems to work but asks me for username/password, which then won’t take my regular password, but wants a token. Obviously, I’m missing something here on using the no id/pass SSH way. I’m on Ubuntu and working from a command line, BTW.

Solution

The syntax for a URL / URI (with some simplifications) is:

scheme://host/path

or:

scheme://user@host/path

The scheme part here is one of http, https, ssh, and so on. So you can simply write:

ssh://git@github.com/path/to/repo

instead of:

ssh://user@github.com/path/to/repo

(you must use the user name git with the ssh scheme because of the way GitHub handles incoming ssh requests).

If you choose to use Git’s own shorthand notation:

git@github.com:path/to/repo

note that there is a colon (:) after the git@github.com part. It must not be eliminated.

Answered By – torek

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published