Bor*_*ard 39 git ubuntu windows-subsystem-for-linux
我试过按照这些说明操作:https://stackoverflow.com/a/40312117/21728基本上这样做:
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
Run Code Online (Sandbox Code Playgroud)
但是当我进行任何网络操作时,我收到此错误:
** (process:7902): CRITICAL **: could not connect to Secret Service: Cannot autolaunch D-Bus without X11 $DISPLAY
Run Code Online (Sandbox Code Playgroud)
这是合乎逻辑的,因为确实没有X11显示器.
如何在Windows(WSL)上的Ubuntu上使Git凭据缓存工作?
Car*_*ler 47
如果您安装了Git for Windows,则系统上会安装Windows集成凭据管理器.
您可以从WSL运行Windows可执行文件,如此处所示.
要使用它,您可以运行以下命令(假设您的git for Windows安装在C:\ Tools\Git上)
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
Run Code Online (Sandbox Code Playgroud)
Bru*_*sky 28
我已经创建了一个脚本来为您完成此操作.我和我的Chef编排一起使用它.
cmd.exe并致电where git-credential-manager.exe
cmd.exe电话中where git.exe
C:\Program Files\Git\cmd\git.exeC:\Program Files\Git\mingw64\libexec\git-core\git-credential-manager.exewhere我们要:
C:\用/mnt/c/\到/\\所以...
"C:\Program Files\Git\mingw64\libexec\git-core\git-credential-manager.exe" 成为..."/mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"bash电话中git config --global credential.helper "<converted/path>"小智 18
使用Windows 10和"WSL",我创建了一个〜/ .gitconfig文件,但错误地将[credential]部分标签输入为[凭证].我尝试运行git凭证填充,然后将其输出提供给git凭证批准,这可能有效,但我怀疑不是因为它说"usage:git credential [fill | approve | reject]".最后,我简单地跑了:
$ git config --global credential.helper cache
Run Code Online (Sandbox Code Playgroud)
然后做了一个git pull; 当提示输入用户和密码时,我像往常一样输入它们.在那之后,它记住了它.我发现它已将(正确命名的)部分添加到我的〜/ .gitconfig中:
[credential]
helper = cache
Run Code Online (Sandbox Code Playgroud)
我编辑它以提供更长的超时:
[credential]
helper = cache --timeout=144000
Run Code Online (Sandbox Code Playgroud)
现在这一切似乎都运转良好.
到目前为止,所有答案都过于复杂。而且 git 文档并没有真正的帮助,他们喜欢参考资料很多,所以你需要按照 2-3 个链接来获取你需要的信息!
git.exe与 WSL一起使用!使用 linux git sudo apt install git-all(我认为它预装了 Ubuntu)。git 默认支持 2 种方法。要查看您安装了哪些方法,请执行以下命令:
git help -a | grep credential
Run Code Online (Sandbox Code Playgroud)
我的结果是:
credential Retrieve and store user credentials
credential-cache Helper to temporarily store passwords in memory
credential-store Helper to store credentials on disk
Run Code Online (Sandbox Code Playgroud)
@selkieTG 在他们的回答中涵盖了这一点,包括完整性......
git config --global credential.helper "cache --timeout 30000"
Run Code Online (Sandbox Code Playgroud)
将您的密码/令牌缓存 30,000 秒(8 小时 20 分钟)
git config --global credential.helper "store"
Run Code Online (Sandbox Code Playgroud)
将纯文本密码/令牌存储在~/.git-credentials.
纯文本?!!对于 WSL,我完全可以在这里使用纯文本。我输入凭据以运行我的 Windows 计算机,然后输入凭据以登录 WSL2。我需要隐藏这些吗?不是真的,它在我的开发箱上更方便。
如果你真的想使用manager-core你可以在你的Ubuntu 版本中安装它。然后使用它。
| 归档时间: |
|
| 查看次数: |
8951 次 |
| 最近记录: |