如何从github克隆项目代码仓储

安装
https://git-scm.com/downloads 下载windows版本并安装。安装过程中使用默认设置即可。
生成并配置密钥对这个步骤是可选的,如果电脑上已经有密钥对,则不用再生成。

1. 从开始菜单中搜索“Git Bash”并打开
2. 执行命令 $ ssh-keygen -t rsa -C "youremail@example.com",参数换成自己的邮件,
一路回车
3. 根据提示,找到生成的公钥文件“id_rsa.pub”,用文本编辑器打开,复制其内容
4. 登录 https://github.com/,点击【右上角头像-Settings-SSH and GPG keys】创建新的
SSH Key,把刚才复制的公钥粘贴进去,给Title起个名字,如“公司电脑”。

配置个人信息
在“Git Bash”中执行命令:
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com

克隆远程仓储
新建本地文件夹github(名字随意)

打开“Git Bash”,cd到这个目录里,比如文件夹在"e:\github",执行命
cd /e/github
执行命令: $ git clone git@github.com:test/testcode.git


关联其它远程分支
$ git checkout -b branchName origin/branchName
如果是新注册的github用户,可能推送不上去,需要登录github验证一下邮箱。










posted @ 2023-02-17 14:21  haishu  阅读(191)  评论(0编辑  收藏  举报