0

I don't want to use web credentials (the password) at all when working with git. Name and e-mail is OK to be stored.

My SSH environment is properly set up in Windows when it starts (the authentication test to Github is successul, from a cmd.exe shell). The SSH keys are not passworded.

I can go to the Github website and create an empty repository, and then use SSH from the terminal within VS Code (Ubuntu/WSL, in which I have created an SSH environment), to push my project to Github.

If I try to use the GUI button to push the project to Github, I get a message "the extension 'Github' wants to sign in using Github". OK, I can live without that and just use the CLI.

I have read that Gitlab can do this but I can't get a clear answer from Github's documentation, or by online search, that Github can't do it, just that their recommended procedure is to first create the empty repo by using the website.

So how can I push my project to a non-existent repo on Github only using SSH?

3
  • 2
    You can't push to a non-existing repository, you have to create it first. You can do so using the GitHub REST API (and use token authentication) or directly use the CLI tools, that make use of that API: cli.github.com
    – Robert
    Commented May 20, 2021 at 16:32
  • See also gist.github.com/alexpchin/dc91e723d4db5018fef8 for a discussion about this topic
    – Bodo
    Commented May 20, 2021 at 16:34
  • Thanks for the comments. If you make your comment an answer, Robert, I'll accept it. Reading the discussion referenced by Bodo persuades me that the new CLI tool, gh, is the way to go as a supplement to git. It does the job and its minor bugs will no doubt be cleaned up before long.
    – Bluebird45
    Commented May 21, 2021 at 13:43

2 Answers 2

0

You cannot use only SSH to create a repository on GitHub. You'll need to use some form of HTTPS:

  • You can create it using the web interface;
  • You can create it using the REST API (or the GraphQL API, if you prefer); or
  • You can create it using the gh command-line client (which use the API under the hood).

If you use the API directly or indirectly, you'll need a personal access token or OAuth token in order to use make the API call. gh will set that up for you if necessary. Note that the token is not your password; it is a secret, but it is pseudorandomly generated, and it is normally stored in a credential helper.

The number of operations that are supported over the SSH interface are intentionally extremely limited: pushes and pulls, Git LFS authentication, and the like.

0

If you wish to avoid typing your password all the time for HTTP/HTTPS, use credential helpers.

Some versions of the Git for Windows installer (e.g. 2.7.4) have a checkbox during the installation for enabling the Git Credential Manager.

enter image description here

If your version does not contain it, you might be helped by the Git-Credential-Manager-Core.

3
  • Thanks but I don't want the password cached because it makes it harder to fully understand what's going on when I use the tools - why an operation is successful and why it isn't, and also for overall security.
    – Bluebird45
    Commented May 21, 2021 at 13:06
  • You will always need some password, stored somewhere and somehow. Or typed.
    – harrymc
    Commented May 21, 2021 at 13:25
  • Not necessarily, harrymc, as proven by the use of SSH in such contexts as remote shell connections and file transfer.
    – Bluebird45
    Commented May 21, 2021 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .