在github上新建一个仓库后,如何将本地文件推送上来

哈哈哈,有图有真相。这张图片的作用是教我们如何把本地文件夹变成一个仓库并且将它与我们在github上的远程仓库相连。
在github上新建一个仓库后,如何将本地文件推送上来_第1张图片
如果遇到了下面的问题

$ git push origin master
To https://github.com/Yinshijia/ShijiaYin.github.io
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Yinshijia/ShijiaYin.github.io'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这是因为你的本地仓库和远程仓库不一样,但你的本地仓库又不是master,所以你是不能直接push的,你需要先使用下面的指令将远程仓库pull下来

 git pull origin master --allow-unrelated-histories

然后再使用

git push -u origin master

就可以了

你可能感兴趣的:(时常忘记)