Git使用命令行指南
- 设置用户名和邮箱
git config --global user.name "xx" // 设置用户名
git config --global user.email "xx@163.com" // 设置邮箱
- 生成ssh密钥
ssh-keygen -t rsa //生成ssh公钥和私钥
备注:在Mac上会出现
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
这一段文字提示需要保存的位置,一般来说使用默认位置,直接键入Enter键即可
还有就是会要求输入密码Enter passphrase (empty for no passphrase): [Type a passphrase]
,一般也建议不键入密码,毕竟时间久了很有可能会忘记
- 生成known_hosts文件(记录了远端网址数据)
ssh -T git@gitee.com
-
TortoiseGit配置
修改ssh客户端为以下路径(视安装路径为准)
-
查看ssh密钥
//Windows
cd ~/.ssh //进入.ssh目录
ls //列出目录中包含的内容
cat id_rsa.sh //查看id_rsa.sh的内容(密钥)
//Mac
ls -al ~/.ssh //查看电脑上是否存在ssh密钥
cat id_rsa.sh //查看id_rsa.sh的内容(密钥)
- 查看gitConfig
git config --list