How to Store Your Git Credentials

This is how you store your Git credentials, so you don’t have to type it everytime you interact with your repository. For source code management, I use gitea hosted at Byte23 Networks.

I use an access token instead of my actual user password. To create it:

  • Login to gitea
  • Click on your profile in the top right
  • Select settings
  • Select Applications
  • Select Generate token
  • Copy the token

Afterwards I configure my Git CLI to use the credential:

% git config --global credential.helper store

The next time I use git pull or some similar command, I will be prompted for my username and password. Here I enter my username, and the API token generated earlier. Be careful: Git will store the credentials in a file called ~/.git-credentials in clear text. So make sure you protect this file appropriately.

I just encrypt the entire disk, the default ACL setting is fine:

% ls -all ~/.git-credentials 
-rw-------  1 tobi  tobi  69 May 24 11:53 .git-credentials