每当我尝试推入我的存储库时,git都会要求用户名和密码。
每次重新输入密码没有问题,但问题是输入用户名。我使用https克隆存储库。
那么,我如何配置git,使它在每次git推送时都不需要用户名。
我是linux新手,但windows git push中的IIRC只要求输入密码。
每当我尝试推入我的存储库时,git都会要求用户名和密码。
每次重新输入密码没有问题,但问题是输入用户名。我使用https克隆存储库。
那么,我如何配置git,使它在每次git推送时都不需要用户名。
我是linux新手,但windows git push中的IIRC只要求输入密码。
当前回答
快速方法
在工作目录中获取git的url:
git config remote.origin.url
那么:
git config credential.helper store
git push "url of your git"
将最后一次询问用户名和密码
完成。
其他回答
解决这个问题的正确方法是将http更改为ssh。
您可以使用此git remote rm源来删除远程回购。
然后,您可以使用ssh-sintax(可以从github复制)再次添加它:git远程添加原点git@github.com:username/reportname.git。
检查这篇文章。https://www.freecodecamp.org/news/how-to-fix-git-always-asking-for-user-credentials/
打开Windows凭据管理器并删除git:https://dev.azure.com/orgname来自通用凭据。有关步骤,请查看为什么带有GIT的TFS无法从命令行工作?从文件夹C:\Users\{username}中删除.git凭据文件。确保从更新git最新版本https://git-scm.com/download/win
我尝试了这些步骤,结果成功了:
创建个性化访问令牌:https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token将令牌添加到Android studio(文件->设置->版本控制->Github->添加-使用令牌登录)转到文件->设置->版本控制->Git并取消选中“使用凭据助手”
除了user701648的答案之外,您还可以使用以下命令将凭据存储在主文件夹(所有项目的全局文件夹)中,而不是项目文件夹中
$ git config --global credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
使用以下命令可以给您15分钟的超时时间。
$ git config --global credential.helper cache
您也可以通过下面的命令修改时间。这是一个1小时的示例。
$ git config --global credential.helper 'cache --timeout=3600'
如果要在本地缓存,请使用该命令一小时以超时。
$ git config credential.helper 'cache --timeout=3600'