Git使用命令行指南

  1. 设置用户名和邮箱
git config --global user.name "xx"    // 设置用户名
git config --global user.email "xx@163.com" // 设置邮箱
  1. 生成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] ,一般也建议不键入密码,毕竟时间久了很有可能会忘记

  1. 生成known_hosts文件(记录了远端网址数据)
ssh -T git@gitee.com
  1. TortoiseGit配置
    修改ssh客户端为以下路径(视安装路径为准)
    image

  2. 查看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的内容(密钥)
  1. 查看gitConfig
git config --list
posted @ 2025-04-15 17:12  请明月  阅读(22)  评论(0)    收藏  举报