我在VS Code中使用git。我在 Azure DevOps 中有一个项目。3 个月前,当我复制 repo 并推送我的第一次提交时,Git 要求提供我的凭据。我输入了用户名并生成了密码。在那之后,一切正常。每次我拉或推VS Code时都会开始询问密码。如何保存密码?
git config credential.helper store
然后 git 会在本地记住你的凭据。该配置也是本地的。
首先检查您使用的网址:
cd /path/to/local/repo
git remote -v
如果是 HTTPS URL,请检查您使用的凭据帮助程序
git config credential.helper
xxx
(例如,manager
或manager-core
)
然后检查附加到远程 URL 的服务器部分dev.azure.com
的凭据:
printf "host=dev.azure.comnprotocol=https" | git credential-xxx get
将xxx
替换为上一步的凭据帮助程序的名称。
即使在Windows CMD中也可以工作,前提是您的%PATH%具有C:Program FilesGitusrbin
和C:Program FilesGitmingw64libexecgit-core
如果未存储凭据,则可以使用git credential-xxx store
再次注册:
printf "username=<you>npassword=<token>nhost=dev.azure.comnprotocol=https" | git credential-xxx store
将<you>
替换为 DevOps 用户名,<token>
替换为 Azure PAT(个人访问令牌)。