hello云胜

技术与生活

0%

linux下配置git保存用户名和密码

在用户根目录(~)下,使用 touch 命令创建文件 .git-credentials :

1
touch .git-credentials
  1. 然后用 vim 命令编辑此文件:
1
vim .git-credentials

按 i 键进入编辑模式,输入:

1
2
http://{你的用户名}:{你的密码}@你的服务器地址
https://{你的用户名}:{你的密码}@你的服务器地址

注意:去掉 {}

  1. 在终端下执行如下命令:
1
git config --global credential.helper store
  1. 可以看到 ~/.gitconfig 文件会多一项:
1
2
3
4
cat .gitconfig

[credential]
helper = store

说明已经配置好了,再次 push 或 pull 试试看吧,不需要输入密码了。