前置知识见:把自己在本地完成的mit6.s081项目上传到自己的github仓库里_mit6.s081 lab上传-CSDN博客
先在github建立一个自己的仓库

由于github可以给自己的主分支改名了,我这次是勾选了创建README文件

在本地同样是建立一条remote分支
git remote add <分支名字> <你仓库的地址>
远程分支建立完成后,如果我们尝试直接将当前文件夹的内容进行提交到仓库里,就会报错"Updates were rejected because the remote contains work that you do hint: not..."
这是因为远程仓库里有README文件,而本地并没有。要先把仓库里的README拉取到本地才行,然后在把本地文件夹一起提交到远程仓库里。
为了尝试把远程仓库里的内容拉取到本地,我可谓是绞尽脑汁。最后重要试出了正确的格式。

git pull <自己创建的远程分支名称> <从自己的仓库哪条分支拉取> --allow-unrelated-histories

将远程仓库的内容成功拉取到本地后,就是经典三板斧操作了。
git add .
git commit -m "自己想说的话"
git push <刚才创建的远程分支名> <本地分支名>:<远程分支名>
我这里提前做了上述前两步操作

