我把我的工作推到一个远程git存储库。
每次推送都会提示我输入用户名和密码。我想避免它的每一个推送,但如何配置以避免它?
我把我的工作推到一个远程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
其他回答
我用了帕维尔建议的答案,它对我很有效。我的区别是这样做,而我是这样添加远程:git远程添加(别名)https://(name:password)@github.com/(the远程地址).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
我使用的是https链接(https://github.com/org/repo.git) 而不是SSH链接;
git@github.com:org/repo.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存储库进行永久身份验证,
运行以下命令启用凭据缓存。
$ 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>
Use还应该指定缓存过期,
git config --global credential.helper 'cache --timeout 7200'
启用凭据缓存后,它将被缓存7200秒(2小时)。
注意:凭据帮助程序将未加密的密码存储在本地磁盘上。