基础配置
1 查看、配置用户信息 🧔
- 配置用户名:
git config --global user.name "yourname"
- 配置用户邮箱:
git config --global user.email "youremail@qq.com"
- 查看用户信息:
git config --global --list
- 查看用户名、邮箱:
git config user.name
,git config user.email
2 配置 ssh 🔑
配置 ssh 后,使用ssh 地址 clone 项目,无需再输入账号密码。一次配置,永久使用。😉
检查 ssh 是否存在
cd ~/.ssh
,找到.ssh
文件夹ls
或ll
,查看是否存在id_rsa.pub
cat id_rsa.pub
,获取秘钥
如果 ssh 不存在,那就 ——
生成秘钥
ssh-keygen -t rsa -C "your-email@qq.com"
生成后就可以通过上述方式找到 ssh,拷贝一下,接下来去 github ——
在 github 中添加秘钥
点击头像 → Settings → SSH and GPG keys → New SSH key → 黏贴 ssh-rsa
开头的串串 → 确定添加 → OK啦! 🎉
关于 ssh 的详细操作和解说,参考: https://www.liaoxuefeng