在指定的目录下,使用指定Github账号拉取远端仓库

380 阅读1分钟
  1. 新建一个目录,在该目录下创建特定的Git用户名和邮箱
$ git config user.email "as_tgl@gmail.com" 
$ git config user.name "as_tgl" 
  1. 创建 ssh 秘钥
$ ssh-keygen -C "as_tgl@gmail.com"

在这一步提示后输入新的秘钥的文件名称(也可以指定特定的文件路径)

Enter file in which to save the key (/Users/as_tgl/.ssh/id_rsa): id_github_rsa 

之后该命令执行步骤可以回车跳过
3. 将秘钥上传到 github 上 获取刚才生成的公钥内容

$ cat ~/.ssh/id_github_rsa.pub 

github.com/settings/ke… 创建一个 SSH Key。
将刚才你生成的公钥内容粘贴到当中
4. 配置本地ssh的配置信息

$ vim ~/.ssh/config

需要在发送请求时,指定特定的私钥进行连接GitHub.com
配置如下

Host github.com 
    HostName github.com
    User git 
    IdentityFile /Users/as_tgl/.ssh/id_github_rsa 
    IdentitiesOnly yes

配置完成后即可使用在拉取分支的时候,使用特定私钥进行git连接
5. clone 你的仓库去吧 (๑•̀ㅂ•́)و✧

$ git clone git@github.com:Veming/algorithm008-class02.git