All the answers are overly complicated to this point. And the git documentation does not really help, they link to reference material a lot so you need to follow 2-3 links to get the info you need!
- You do not need to use Windows
git.exe
with WSL! Use linux git sudo apt install git-all
(I think it comes pre-installed with Ubuntu).
- Then you can simply follow the instructions at https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage.
Summary
git supports 2 methods by default. To see what methods you have installed, execute this command:
git help -a | grep credential
my result was:
credential Retrieve and store user credentials
credential-cache Helper to temporarily store passwords in memory
credential-store Helper to store credentials on disk
How to for cache & store:
@selkieTG covers this in their answer, including for completeness...
git config --global credential.helper "cache --timeout 30000"
will cache your password/token for 30,000 seconds (8 hrs 20min)
git config --global credential.helper "store"
will store plain text password/token in ~/.git-credentials
.
Plain Text?!! For WSL, I am absolutely OK with plain text here. I enter credentials to run my Windows machine and I enter credentials to sign into WSL2. Do I need to hide these? Not really, it is more of a convenience on my dev box.
If you really want to use manager-core
you can install it in your Ubuntu version. And then use it.