每当我尝试推入我的存储库时,git都会要求用户名和密码。
每次重新输入密码没有问题,但问题是输入用户名。我使用https克隆存储库。
那么,我如何配置git,使它在每次git推送时都不需要用户名。
我是linux新手,但windows git push中的IIRC只要求输入密码。
每当我尝试推入我的存储库时,git都会要求用户名和密码。
每次重新输入密码没有问题,但问题是输入用户名。我使用https克隆存储库。
那么,我如何配置git,使它在每次git推送时都不需要用户名。
我是linux新手,但windows git push中的IIRC只要求输入密码。
当前回答
git-config credential.helper存储git推/推https://github.com/xxx.git然后输入您的用户名和密码。多恩
其他回答
使用Git存储库永久验证
运行以下命令以启用凭据缓存:
$ git config credential.helper store
$ git push https://github.com/repo.git
Username for 'https://github.com': <USERNAME>
Password for 'https://USERNAME@github.com': <PASSWORD>
使用还应指定缓存过期
git config --global credential.helper "cache --timeout 7200"
启用凭据缓存后,将缓存7200秒(2小时)。
读取凭证文档
$ git help credentials
设置全天(即24小时)的凭据。
git config --global credential.helper 'cache --timeout=86400'
否则1小时,将86400秒替换为3600秒。
OR
“缓存”身份验证助手的所有配置选项:
git帮助凭据缓存
有关详细信息:https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git
你可以跑了
git config --global credential.helper wincred
在您的系统中安装并登录GIT for windows之后。
您可以在本地存储库的.git/config文件中完成此操作。此文件包含一个名为“remote”的节,其中包含名为“url”的条目。“url”条目应包含您正在讨论的存储库的https链接。
当您在主机“url”前面加上用户名时,git不应该再要求您输入用户名。下面是一个示例:
url = https://username@repository-url.com
ssh+密钥身份验证比https://credential.helper更可靠
您可以配置为对所有存储库使用SSH而不是HTTPS,如下所示:
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
网址<此处记录了base>.installOf。