When accessing different git repo hosts (GitHub, GitLab etc.) via HTTPS it’s necessary to enter your credentials. Fortunately, git offers a convenient way to automate this process by securely storing your credentials.
First, I needed to enable the credential helper:
> git config credential.helper store
Next up, I cloned a remote repository via HTTPS. git asked for the personal GitHub access token I previously generated (on GitHub under Settings → Developer settings → Personal access tokens
):
> git clone https://carlo@github.com/carlo/whatever-whatever.git
Cloning into 'whatever-whatever'...
Password for 'https://carlo@github.com':
Once I entered the password, my login info was saved in ~/.git-credentials
:
> cat ~/.git-credentials
https://carlo:ghp\_XM…………………………………………………………………OXRLVaI……@github.com
Naturally, I prefer using SSH but for those times when that’s not an option, my life got easier because I learned about the credentials storage.
Hat tip to this TecMint article and the git-credential-store
documentation for teaching me new things.
Tags: #til #git #github