版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhuyunier/article/details/83751142
1、点击New respository,创建一个仓库;
2、填写仓库名字以及描述,勾选Initialize this repository with a README会自动生成README;
3、创建完成后会有如下界面:
4、因为本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以需要配置ssh key。在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,Windows下打开Git Bash,使用以下命令创建SSH Key:
ssh-keygen -t rsa -C "[email protected]"
需要把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可,可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。
5、登陆GitHub,打开“Account settings”,“SSH and GPG Keys”页面,点击New SSH Key;
6、创建New SSH Key后,填写Title,在Key文本框里粘贴id_rsa.pub文件的内容;
点击Add SSH Key后,便可以看到已经添加的Key:
7、验证是否成功,在git bash里输入下面的命令:
ssh -T [email protected]
第一次设置的话,会出现如下界面,输入yes 同意即可
8、使用以下命令设置username和email;
git config --global user.name "name"//你的GitHub登陆名
git config --global user.email "[email protected]"//你的GitHub注册邮箱
9、点开刚才创建的仓库,复制远程仓库的SSH;
10、依次使用以下命令将本地仓库传到github上去。
git init
touch 1.txt
git add 1.txt
git commit -m "first commmit"
git remote add origin [email protected]:cjnV587/test.git
git push -u origin master