试用场景
Windows系统下,项目创建好以后,第一次将项目上传到github的仓库中,同时当前电脑并没有配置github的SSH Key
安装Git
windows下载Git安装包然后无脑安装即可,同时查看环境变量里的path有没有Git的配置,没有请添加,默认情况下应该是Git安装程序自动给配置了。
配置windows系统的SSH,如果已经配置可以忽略
1、生成RSA密钥对
打开Git Bash然后输入如下命令
cd ~ //进入到根目录
ssh-keygen -t rsa -C "Github邮箱@126.com" //生成rsa公钥和私钥,此邮箱应该为github的Primary邮箱,如果不是应该是不能通过ssh访问github的
注:配置Github主邮箱

2、将公钥配置到github
打开github在用户-->settings-->ssh and gpg keys然后添加ssh key

3、测试ssh key是否配置成功
输入如下命令:
ssh -T git@github.com

出现上面的提示然后打个yes回车即可,到此ssh配置成功。
上传项目到Github
通过cd 目录进入到项目目录,比如项目在G盘mygit中的lucky_go中,需要输入如下命令:
cd /g cd mygit/lucky_go
git初始化
git init
git添加
git add .
查看Git状态
git status
提交
git commit -m firstbuild //firstbuild 是注释必须填写不然提交不成功
设置Git仓库git(在设置之前要在github网站上创建一个仓库)
git remote add origin git@github.com:仓库目录.git
push到github
git push -u origin master
网友评论