Home > Enterprise >  SSH local to github confusion
SSH local to github confusion

Time:11-20

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 [email protected]

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

git remote add origin [email protected]/mygithub/myrepo.git
git push -u origin master

I get

fatal: '[email protected]/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.

CodePudding user response:

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://[email protected]/path/to/repo

instead of:

ssh://[email protected]/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:

[email protected]:path/to/repo

note that there is a colon (:) after the [email protected] part. It must not be eliminated.

CodePudding user response:

You're using the wrong URL. It should be:

git remote add origin [email protected]:mygithub/myrepo.git
git push -u origin master

Note that there's a : between github.com and your username, not a slash.

Also, make sure that the repository exists before you push it. If you haven't created it on github then you won't be able to push it.

  • Related