首先cd 到要上传代码的问价夹
然后:
touch README.md
git init (初始化本地代码库)
git add README.md (README.md里面写要上传代码的使用说明,和实现的功能)
git commit -m “first commot” (“ ” 引号里面的内容为要上传的代码的描述)
git remote add origin http://… (https://…为代码库的地址)
git push -u origin master (-u)为第一次上传时添加
若出现问题如上图解决。
还要注意,将本地的公钥添加到要上传平台中。
如何获取本地公钥:
windows:
使用ssh-keygen生成本地公钥。
cat ~/.ssh/id_rsa.pub,将复制得到的公钥,添加到你所要上传的代码库的平台中。
linux:
ssh-keygen -t rsa -C “xxx@email.com”
查看ssh公钥
cat ~/.ssh/id_rsa.pub
将ssh配置到github