专业的编程技术博客社区

网站首页 > 博客文章 正文

git 不需要输入密码配置的两种方式

baijin 2024-10-10 04:22:49 博客文章 6 ℃ 0 评论

#git#

#github#

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"
12

确认ssh-agent开启

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

添加到github

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

git 缓存用户名密码

git config  credential.helper store
1

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

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表