How to use Git credential store on WSL (Ubuntu on Windows)?

Borek Bernard picture Borek Bernard · Aug 28, 2017 · Viewed 21.5k times · Source

I've tried following these instructions: https://stackoverflow.com/a/40312117/21728 which basically do this:

sudo apt-get install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret

But when I do any network operation, I get this error:

** (process:7902): CRITICAL **: could not connect to Secret Service: Cannot autolaunch D-Bus without X11 $DISPLAY

That's logical I guess as there is indeed no X11 display.

How to make Git credentials caching work on Ubuntu on Windows (WSL)?

Answer

Carlos Beppler picture Carlos Beppler · Nov 17, 2017

If you installed Git for Windows there is a windows integrated credential manager installed on your system.

You can run windows executables from WSL as found here.

To use it you can run the following command (assuming that your git for windows is installed on C:\Program Files\Git)

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