Try git-credential-manager
Last updated on 2022-03-16, Wed, 03:19 PM
How I Found This
I am a user of several git platforms and hold more than one identity on one of them.
SSH is out of the question and will never be used in my lifetime.
So for me, credential management is a big problem: using shipped plaintext credential store is obviously too dangerous, but I don’t want to have to enter the password every time.
Then I happened to see a glimmer of hope in the comments section of Haruhi’s sometime tweet.
git-credential-manager
is exactly what I want.
Installation
Please refer this .
Configuration
For gitea, it is recommended to specify the authentication source as generic
beforehand.
Windows
Use DPAPI to encrypt credentials. [1]
If you don’t need to use it globally, please restore the credential.helper
properties in your home directory to avoid any inconvenience.
Linux
Use GPG / pass
for encryption. [2]
API by freedesktop.org frequently fails to communicate with gcm and will lose your credentials.
It is recommended to generate a separate key for encryption.
Initialize pass
. Don’t contain spaces when entering Key ID.
Edit .gitconfig
.
Multi-User
Add username in front of the hostname in the remote url. [3]
Like this:
Limit the effective range of .gitconfig
Here you need to use git’s conditional includes feature.
Find the .gitconfig
file in your $HOME
/ %HOME%
directory and add
Adding /
at the end is equivalent to a wildcard to /**
, which will work for all subdirectories below.
The prefix ~/
is relative to the home directory, while ./
is relative to the directory this .gitconfig
is located in.
Also, you can nest multiple .gitconfig
files.
For duplicate configurations, the closer the file is to .git/config
in the actual git repository, the higher its priority.
In this way, you can restrict your credential store settings to certain directories.
Done, once and for all.
Ref
- https://github.com/GitCredentialManager/git-credential-manager/blob/main/docs/credstores.md#windows-credential-manager ↩
- https://github.com/GitCredentialManager/git-credential-manager/blob/main/docs/credstores.md#gpgpass-compatible-files ↩
- https://github.com/GitCredentialManager/git-credential-manager/blob/main/docs/multiple-users.md ↩