linux下配置git保存用户名和密码
在用户根目录(~)下,使用 touch 命令创建文件 .git-credentials :
1 | touch .git-credentials |
- 然后用 vim 命令编辑此文件:
1 | vim .git-credentials |
按 i 键进入编辑模式,输入:
1 | http://{你的用户名}:{你的密码}@你的服务器地址 |
注意:去掉 {}
- 在终端下执行如下命令:
1 | git config --global credential.helper store |
- 可以看到 ~/.gitconfig 文件会多一项:
1 | cat .gitconfig |
说明已经配置好了,再次 push 或 pull 试试看吧,不需要输入密码了。