git 免输入用户名密码

分两种方式:通过ssh key以及git本地缓存用户名密码

ssh key

总体步骤:本地创建公钥私钥。将私钥放在~/.ssh下,公钥放到github

创建Key

$ ssh-keygen -t ed25519 -C "your_email@example.com" 或者
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

确认ssh-agent开启

eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_ed25519 或者
$ ssh-add ~/.ssh/id_rsa

添加到github

user->setting->SSH and GPG keys
拷贝 ~/.ssh/id_ed25519.pub 或者 ~/.ssh/id_rsa.pub 内容

git 缓存用户名密码

git config  credential.helper store

~/.gitconfig 中会多出一个配置
输入密码后,git会缓存用户名密码,之后不需要再输入。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐