我把我的工作推到一个远程git存储库。

每次推送都会提示我输入用户名和密码。我想避免它的每一个推送,但如何配置以避免它?


当前回答

只是想指出上面说过几次的解决方案:

git config credential.helper store

在此之后,您可以使用任何需要密码的命令。你不需要用力。之后,你就不需要再输入你的用户名/密码了。

其他回答

运行下面的命令为我解决了这个问题。

git config --global credential.helper wincred

请参考以下github文档:

https://help.github.com/articles/caching-your-github-password-in-git/

在Windows操作系统上使用这个代替,这对我来说是有效的:

https://{Username}:{Password}@github.com/{Username}/{repo}.git

e.g.

git clone https://{Username}:{Password}@github.com/{Username}/{repo}.git

git pull https://{Username}:{Password}@github.com/{Username}/{repo}.git

git remote add origin https://{Username}:{Password}@github.com/{Username}/{repo}.git

git push origin master

如果您已经设置了SSH密钥,并且仍然得到密码提示,请确保表单中有您的回购URL

git+ssh://git@github.com/username/reponame.git

而不是

https://github.com/username/reponame.git

要查看您的回购URL,运行:

git remote show origin

你可以像这样用git remote set-url修改URL:

git remote set-url origin git+ssh://git@github.com/username/reponame.git

我在Windows上的解决方案:

右键单击目录,并选择“Git Bash Here”。 ssh-keygen -t rsa(所有值都按enter键) 您的公钥已保存在/c/Users/<your_user_name_here>/.ssh/id_rsa.pub 从指定文件复制公钥。 去你的GitHub配置文件=>设置=> SSH和GPG密钥=>新的SSH密钥=>粘贴您的SSH密钥=>保存

只是想指出上面说过几次的解决方案:

git config credential.helper store

在此之后,您可以使用任何需要密码的命令。你不需要用力。之后,你就不需要再输入你的用户名/密码了。