初次运行 git 全局配置
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
如何生成公钥
- 确定已经配置过用户信息,配置过可忽略
 
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- 生成私钥和公钥
 
cd ~
ssh-keygen -t rsa
按回车3下(为什么按三下,是因为有提示你是否需要设置密码,如果设置了每次使用Git都会用到密码,一般都是直接不写为空,直接回车就好了)
之后会在一个文件夹里面生成一个私钥 id_rsa和一个公钥id_rsa.pub,
默认文件夹在你打开git bash的目录,或者在你的用户目录~/.ssh文件夹下
- 查看公钥
 
cat ~/.ssh/id_rsa.pub  
- 把公钥复制到你需要的地方,例如码云的安全设置中的ssh公钥,这样以后可以直接通过ssh访问仓库了
 

image.png