Why is the HTTPS option still offered

Why is the HTTPS option still offered as a git clone option after creating a new repo ?
I thought it was only going to be SSH.

HTTPS is still offered. What was disabled is password auth, you have to use a PAT now.

So, you can use HTTPS to clone the repo, but then you have to use SSH to push to the remote repo ?

What is PAT ?

PAT - Personal Access Token
It is what you can use to set up integrations with other systems.

HTTPS and SSH are both valid ways to both clone repos as push to them. You can use HTTPS to clone/push, or you can use SSH to clone push. For many companies, HTTPS is easier, because they don’t open port 22 in their firewalls to allow for SSH. And for some developers, they find HTTPS easier to manage that SSH keys. So it really is your preference.

3 Likes

See Creating a personal access token - GitHub Docs for details on Personal Access Tokens, including how to create them. At the bottom of the page is a description of how to use the token with Git.

1 Like

PAT, like the public / private SSH keys ?

If you clone via HTTPS, doesn’t that use a login and/or email / password to push ?

1 Like

Is the PAT same as SSH public / private keys ?

1 Like

No, it’s a completely separate thing, see the documentation link I posted above. In practice it works like a password for specific actions only, so the damage if lost is limited: Of course the ability to push to your repositories is still pretty critical, but someone with a stolen PAT still can’t log in to your account.

So, you create the PAT in the github account settings then somehow copy / import it into your local git installation.

Or create a SSH key either with SSH key-gen or git in the terminal and copy / paste that into your guthub account. which is what I did.

Just was not expecting to see the https git option once ssh took over.

2 Likes

Some devs don’t know how to generate ssh keys locally and add it to their github account ?

I usually clone via SSH when I want to push to an open-source repository, but it’s just so much simpler to clone via HTTPS when I have no intention of contributing, or the use case is a server or IoT or other headless use case

1 Like

HTTPS with modern web based authentications are way more convenient than using SSH keys. You just need to be logged into your GitHub account on web then you can authorize https push from the web browser pop up, presented by client. For instance, on windows, Git authentication works with GUI through default git distribution.
And yes, entering your login, password and otp is way more convenient than copying files around into special locations, considering that you would have to generate and authenticate keys first, which requires logging in to web anyway…

1 Like

Why do you think cloning via https is simpler ?

Well, we no longer have the password option and generating ssh keys and then copying it to my account was easy. have not done the PAT thing yet though.

You don’t use PAT directly. Well… You can, but it is not what is intended for. It is integrated into git client. Try to clone your private repo with HTTPS and then push to it. If you’re on Windows, it will bring up an authentication window.

I use Linux. if I clone via https then push, what will come up ? a prompt for login or pat ?

It will be a login prompt, you will enter your username and then for the Password you paste in the PAT
The PAT must have certain privileges to read and push. When making the PAT check the repo box and the read:org box.

On Linux the downside to this method is you will have to authenticate each time you read or push to a protected repo. However GitHub made this awesome CLI that contains a git credential helper that will cache your PAT locally so you don’t have authenticate every time. After downloading simply enter gh auth login and follow the prompt, again paste in the PAT when prompted for a password, all passwords via command line are PAT now.

Is the GH CLI new ? never heard of it until recently.
I do have it installed and will store the PAT if I ever use https for cloning again.
SSH keys are working for my pushes.

If I clone via GH CLI how do I push ? with SSH keys or a PAT ? or ?
What if I clone via GH desktop ?

1 Like

I think GH CLI has been around for a year or two, it replaces the older hub CLI.

If you have everything installed properly and a PAT cached, then every time you read or push an https cloned repo it should just automagically work with a regular git push or git clone, you don’t need to use the gh commands for basic things.

After you cache a PAT check your ~/.gitconfig file, you should see something like this:
[credential “https://github.com”]
helper =
helper = !/usr/bin/gh auth git-credential
That’s what telling the git command to check the helper before attempting an https pull/push. Also the token itself is cached at ~/.config/gh/hosts.yml

1 Like