By default, the git client in Windows Subsystem for Linux (WSL) will prompt me for credentials each time I access Github. The following steps will make the auth information sticky:
Create a Personal Access Token If Not Already
- Sign in to Github
- Create a (fine-grained as recommended) Personal Access Token under Settings > Developer Settings > Personal access tokens > Fine-grained tokens (https://github.com/settings/personal-access-tokens)
- Copy the token (“
github_pat_....“) and save it somewhere. It’s one of those annoying security phenomena when they show me something ONCE and ONCE ONLY.
Verify Git and Git Credential Manager
- Open up a Windows terminal. Find where git is:
C:\Users\van>where git
D:\Program Files\Git\cmd\git.exe
- Ensure that
git-credential-manager.exeexists in the git installation (currently undermingw64\bin\, though subject to change of course, when they feel like it):
C:\Users\van>dir "D:\Program Files\Git\mingw64\bin\git-credential-manager.exe"
...
03/17/2025 06:08 AM 139,712 git-credential-manager.exe
1 File(s) 139,712 bytes
Configure Use of Git Credential Manager in WSL
- Open up a WSL terminal.
- Tell
gitto use the credential manager (use/mnt/dto indicateD:drive, for example, and use/instead of\for path separator):
$ git config --global credential.helper "/mnt/d/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
- Confirm that the setting is done:
$ cat ~/.gitconfig
[credential]
helper = /mnt/d/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe
The next time I enter the credentials, they will be stored for the future.
By the way, the token is used as the password.