git 实现 https 免密提交

git ssh 方式免密提交方式需要将 ssh-keygen 生成的公钥放到服务器上

git https 则需要每次都输入用户名和密码,目前也没有双方都经过认证的比较安全的免密方式,只能将用户名和密码明文保存在本地,由 git 保管.

git https 实现免密登陆步骤如下

1
2
3
cd ~
touch .git-credentials
vim .git-credentials

添加内容,格式如下

1
2
https://{username}:{password}@{gitserver}
http://{username}:{password}@{gitserver}

将其添加到 git global config 中

1
git config --global credential.helper store

查看 ~/.gitconfig 是否包含以下内容

1
2
[credential]
helper = store

正常的话 git 推送 http/https 链接的 repository 都不需要再输入密码