每次推送时,Git 都要求输入用户名 [英] Git asks for username every time I push
问题描述
每当我尝试推送到我的 repo 时,git 都会要求 username &密码
.
Whenever I try to push into my repo git asks for both username & password
.
我每次都重新输入密码没有问题,但问题在于输入用户名.我使用 https
来克隆我的存储库.
I have no problem in re-entering my password each time but the problem is in entering username. I use https
to clone my repository.
那么,我如何配置 git 以便它不会在每个 git push
上要求 username
.
So, how can I configure git so that it doesn't asks for username
on each git push
.
我是 Linux 新手,但 Windows 中的 IIRC git push
只要求输入密码.
I am new to linux but IIRC in windows git push
only asks for password.
推荐答案
编辑(由@dk14 由版主和评论建议)
警告:如果您使用答案中的 credential.helper store
,您的密码将完全未加密(原样")存储在 ~/.git-凭据
.请参阅下面的评论部分或链接"部分的答案,尤其是在您的雇主对安全问题零容忍的情况下.
WARNING: If you use credential.helper store
from the answer, your password is going to be stored completely unencrypted ("as is") at ~/.git-credentials
. Please consult the comments section below or the answers from the "Linked" section, especially if your employer has zero tolerance for security issues.
即使被接受,它也没有回答实际的 OP 关于仅省略用户名(不是密码)的问题.对于有这个确切问题的读者,@grawity 的answer 可能会派上用场.
Even though accepted, it doesn't answer the actual OP's question about omitting a username only (not password). For the readers with that exact problem @grawity's answer might come in handy.
原答案(@Alexander Zhu):
您可以使用以下命令存储您的凭据
You can store your credentials using the following command
$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
另外我建议你阅读$ git 帮助凭据
Also I suggest you to read
$ git help credentials
这篇关于每次推送时,Git 都要求输入用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!