DEV Community

Discussion on: 10+ things I always setup in git when I prepare a new environment

Collapse
 
piyushnags profile image
Piyush

I read that git push isn't supported fromthe CLI due to security reasons. Is there a nice way to get around that (other than using Github Desktop)?

Collapse
 
snaka profile image
Shinji NAKAMATSU • Edited

Sorry, I didn't catch what you meant by "git push isn't supported formthe CLI due to security reasons".
Could you please add what you mean by that?

Collapse
 
piyushnags profile image
Piyush • Edited

Yep my bad, I wasn't clear enough and I also realized I didn't read the documentation properly :(. I was trying to push some changes to my repo through the terminal. However, I was trying to push via HTTPS. According to GitHub, it no longer supports authenticating through HTTPS for the CLI (I had mistakenly assumed that pushing from CLI in all cases was no longer supported, which is pretty silly in hindsight). After I switched to SSH as suggested by Nathan (from the below response), it works just fine. Side note: great tips now that I can use CLI again!

Edit: If you're curious, you get a 'fatal authentication' error if you try to push via HTTPS. Apparently, they stopped this since August 2021.

Thread Thread
 
snaka profile image
Shinji NAKAMATSU

Ah, it was clear to me what you said.
I'm pleased that your problem was resolved as a result.

Thread Thread
 
jasperhorn profile image
JasperHorn • Edited

git push, from the command line, to GitHub, over https does work. It's just that you don't use your password to login. Instead, you use a token, which you first need to generate in your settings somewhere.

Thread Thread
 
snaka profile image
Shinji NAKAMATSU • Edited

Thank you for the additional information.
As you mentioned, it is possible to push via HTTPS with the git command by using a Personal access token (PAT).

Here is a link to the GitHub documentation for reference.

docs.github.com/en/authentication/...

Collapse
 
nstvnsn profile image
Nathan Stevenson • Edited

I use git push from the CLI all the time. I think you may have read that where it talks about setting up ssh keys.

If you are using your IDE or the Desktop UI for git, you are likely signed in to your github account through them. No issues.

With CLI, you need to set up SSH for authenticating your pushes from the CLI:

docs.github.com/en/authentication/...

Collapse
 
piyushnags profile image
Piyush

Thank you, after switching to SSH it works just fine

Thread Thread
 
nstvnsn profile image
Nathan Stevenson

No problem! Glad you got it working.