sourceTree跳过用户名和密码
sourceTree是一款免费的Git客户端管理工具,界面简洁,操作方便。但是每次更新代码都需要输入用户名和密码,不胜其烦!
1 确定项目地址
可以看下每次输入用户名和密码的提示:
http://xxx.xxx.xxx.xxx
2 在Git中存储用户名和密码
在%HOME%目录中,一般在 c:/users/{当前用户名} 目录下。创建文件名为.git-credentials,由于在Window中不允许直接创建以"."开头的文件,可以借助git bash,打开git
bash客户端,进入%HOME%目录,执行以下操作:
touch .git-credentials
vim .git-credentials
输入以下内容:
http://{用户名}:{密码}@xxx.xxx.xxx.xxx
3 添加Git Config配置项
进入git bash终端, 输入如下命令:
git config --global credential.helper store
执行完后查看%HOME%目录下的.gitconfig文件,会多了一项。
[credential]
helper = store
4 重新打开git bash会发现git push时不用再输入用户名和密码
--Simplicity is the ultimate sophistication.