VS Code:推拉总是要求输入密码

IBl*_*ngl 12 git visual-studio-code

我在 VS Code 中使用 git。我在 Azure DevOps 中有一个项目。3 个月前,当我复制存储库并推送我的第一个提交时,Git 要求我提供凭据。我输入了用户名并生成了密码。之后一切工作正常。每次我拉或推 VS Code 时都会要求输入密码。我怎样才能保存我的密码?

son*_*ing 23

git config credential.helper store
Run Code Online (Sandbox Code Playgroud)

然后 git 会在本地记住你的凭据。该配置也是本地的。


Von*_*onC 2

首先检查您正在使用的 URL:

cd /path/to/local/repo
git remote -v
Run Code Online (Sandbox Code Playgroud)

如果它是 HTTPS URL,请检查您使用的凭据助手

git config credential.helper
xxx
Run Code Online (Sandbox Code Playgroud)

(例如,managermanager-core

然后检查附加到dev.azure.com远程 URL 的服务器部分的凭据:

printf "host=dev.azure.com\nprotocol=https" | git credential-xxx get
Run Code Online (Sandbox Code Playgroud)

替换xxx为上一步的凭据助手的名称。

即使在 Windows CMD 中,只要您的 %PATH% 有C:\Program Files\Git\usr\bin并且C:\Program Files\Git\mingw64\libexec\git-core

如果您的凭据未存储,您可以通过以下方式重新注册git credential-xxx store

printf "username=<you>\npassword=<token>\nhost=dev.azure.com\nprotocol=https" | git credential-xxx store
Run Code Online (Sandbox Code Playgroud)

替换<you>为您的 DevOps 用户名和<token>Azure PAT(个人访问令牌)