Git Push clone避免每次输入用户名和密码的方法

简介:

 本地git环境采用Git-1.9.5-preview20150319与TortoiseGit-1.8.16.0-64搭建而成,但是每次进行克隆或提交操作都需要输入一次账号密码,这样不仅浪费了大量的时间而且降低了工作效率。在此背景下,通过搜索引擎找到了相关解决办法,现总结如下。


如下图,需要输入用户名密码。

wKioL1ZzxIHQ-30aAAE0_r1VICM094.jpg


【解决办法】

进入家目录下

1
C:\Users\ "username"

其中username为你的电脑用户名。

然后创建一个"_netrc"文件。(Linux下是~/.netrc)

wKioL1ZzwrmAS5OUAAA5midmMNQ784.jpg

接着按以下内容格式编辑此文件即可。

1
2
3
4
5
6
machine <hostname1>    #将"<hostname1>"替换为你的主机ip或域名,如github.com
login <login1>         #将"<login1>"替换为你的用户名
password <password1>   #将"<password1>"替换为你的密码
machine <hostname2>    #若你有多个git账号,按上面的格式添加即可
login <login2>
password <password2>

然后,再次执行git clone,即可免密码克隆。

【后续】

这里_netrc文件是用明文存储的账号密码,安全性较低。可使用gpg4Win Lite工具将加密netrc文件。

下载地址:http://files.gpg4win.org/Beta/

使用说明参考:http://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-github/18362082#18362082(Step-by-Step instructions for Windows

)




本文转自 xoyabc 51CTO博客,原文链接:http://blog.51cto.com/xoyabc/1726132,如需转载请自行联系原作者

相关文章
|
2天前
|
开发工具 git
蓝易云 - 解决git clone时出现Failed to connect to 127.0.0.1 port 1573问题
希望这些信息能帮助你解决问题。如果问题仍然存在,可能需要检查你的网络设置或者联系你的网络管理员。
12 3
|
7天前
|
开发工具 git
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
17 1
|
12天前
|
存储 开发工具 git
蓝易云 - git中,add到暂存区,commit且push之后,暂存区域里还有内容吗
所以,当你执行 `git add`,然后是 `git commit`,最后是 `git push`之后,暂存区是空的,除非你又执行了新的 `git add`命令来添加更多的更改。
16 1
|
14天前
|
开发工具 git
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
|
12天前
|
开发工具 git
Git恢复之前版本的两种方法reset、revert(图文详解)
Git恢复之前版本的两种方法reset、revert(图文详解)
11 0
|
18天前
|
开发工具 git
git push xxx not found问题解决
git push xxx not found问题解决
|
开发工具 git
git push报错:The current branch master has no upstream branch
git push报错:The current branch master has no upstream branch
31869 0
git push报错:The current branch master has no upstream branch
|
项目管理 开发工具 git
git push 报错 pre-receive hook declined
git push 报错 pre-receive hook declined
3350 0
git push 报错 pre-receive hook declined
|
1月前
|
开发工具 git
完美解决git 执行git push origin master指令 报错command not found
完美解决git 执行git push origin master指令 报错command not found
41 0
|
11月前
|
存储 开发工具 git
使用 git push 上传超过100MB文件报错 remote: error: this exceeds GitHub‘s file size limit of 100.00 MB
Git 大文件存储(LFS)用 Git 中的文本指针替换音频示例、视频、数据集和图形等大文件,同时将文件内容存储在 GitHub.com 或 GitHub Enterprise 等远程服务器上。
238 0