如何在WSL上使用Git凭证存储(Windows上的Ubuntu)?
问题描述:
我试过以下说明:https://stackoverflow.com/a/40312117/21728基本上做到这一点:如何在WSL上使用Git凭证存储(Windows上的Ubuntu)?
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
但是当我做任何网络操作,我得到这个错误:
** (process:7902): CRITICAL **: could not connect to Secret Service: Cannot autolaunch D-Bus without X11 $DISPLAY
这是合乎逻辑的我猜的有确实没有X11显示器。
如何使Git证书在Windows上的Ubuntu上工作(WSL)?
答
如果您安装了Git for Windows,则系统上会安装Windows集成的凭证管理器。
您可以从WSL运行Windows可执行文件,如发现here。
要使用它,你可以运行下面的命令(假设你的Windows Git是安装在C:\工具\ GIT)
git config --global credential.helper "/mnt/c/Tools/Git/mingw64/libexec/git-core/git-credential-wincred.exe"
答
使用Windows 10和 “WSL”,我创建了一个〜/ .gitconfig文件,但将[凭证]部分标签错误输入为[凭证]。 我试着运行git凭证填充,然后将其输出提供给git凭证批准,这可能已经奏效,但我怀疑没有,因为它说“用法:git凭证[填写|批准|拒绝]”。 最后我简单地跑了:
$ git config --global credential.helper cache
然后做了一个git pull;当提示输入用户名和密码时,我照常输入它们。之后,它记起它。我发现它已经增加了(正确命名的)部分,我的〜/的.gitconfig:
[credential]
helper = cache
我编辑的,以提供更长的超时:
[credential]
helper = cache --timeout=144000
而这一切似乎很好地工作现在。
这是关于Windows的Windows子系统(WSL),而不是MSysGit。您无法在WSL内部安装Git for Windows。 –
好的,你不能安装,但你可以使用WSL的windows可执行文件,所以你可以使用git上的凭证助手来运行WSL上的git。这个配置是从我自己的机器上复制的。 –
'git config --global credential.helper“/ mnt/c/Program \ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe”'这是我使用的命令。如果你有一个空间的路径,你需要转义它,并把它放在引号中。 – masters3d