DEV Community

Cover image for Sharing Git credentials between Windows and WSL
Camilo Martinez
Camilo Martinez

Posted on • Edited on

21

Sharing Git credentials between Windows and WSL

Download Git for Windows and choose Git Credential Manager (GCM) as credential helper on the installation steps.

gcm

If you use HTTPS to clone your repositories, you can share this with WSL so that passwords you enter are persisted on both sides.

Note that this does not apply to using SSH keys.

Just follow these steps:

  1. Configure the credential manager on Windows by running the following in a Windows command prompt or PowerShell:

     git config --global credential.helper wincred
    
  2. Configure WSL to use the same credential helper, but running the following in a WSL terminal (assuming you have git >= v2.39.0):

     git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
    

To know the path for previous versions of git, please refer to https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-git

Any password you enter when working with Git on the Windows side will now be available to WSL and vice versa.


Bonus Track


That’s All Folks!
Happy Coding 🖖

beer

Sources

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (2)

Collapse
 
rafaspimenta profile image
Rafael Pimenta

And for ssh key?

Collapse
 
equiman profile image
Camilo Martinez

SSH works different. The credential helper is for storing https credentials, not ssh passphrase ones for private keys.

Take a look of Working with SSH key passphrases

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more