每当我尝试推入我的存储库时,git都会要求用户名和密码。

每次重新输入密码没有问题,但问题是输入用户名。我使用https克隆存储库。

那么,我如何配置git,使它在每次git推送时都不需要用户名。

我是linux新手,但windows git push中的IIRC只要求输入密码。


当前回答

打开Windows凭据管理器并删除git:https://dev.azure.com/orgname来自通用凭据。有关步骤,请查看为什么带有GIT的TFS无法从命令行工作?从文件夹C:\Users\{username}中删除.git凭据文件。确保从更新git最新版本https://git-scm.com/download/win

其他回答

确保您使用的是SSH而不是http。检查此SO答案。

您可以通过在Git配置文件中放置以下内容来设置给定站点上所有存储库的用户名。你会想改变的”https://example.com“和”我“添加到实际URL和您的实际用户名。

[credential "https://example.com"]
    username = me

(这直接来自“git help credentials”)

除了user701648的答案之外,您还可以使用以下命令将凭据存储在主文件夹(所有项目的全局文件夹)中,而不是项目文件夹中

$ git config --global credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
git config --global credential.helper cache

当我只使用git pull,git pull-origin xxx时,git会同时要求用户名和密码。

git config credential.helper store

它起作用。