这次我是想把写好的作业上传到github上,
- 首先我在github上面新建了一个repository
- 又在本地 git init建立了一个git仓库
- 然后在git add commit后,使用命令
git remote add origin 远程仓库地址
没有消息。。。然后我就想起我老师说,没有消息就是好消息,然后我就想上传代码
git push -u origin master
发现报错了 ,报的是
To https://github.com/tjucaokun/photowall.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/tjucaokun/photowall.git'
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.
这我感觉应该是冲突了,所以我想pull一下,然后他又报了错
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/tjucaokun/photowall * branch HEAD -> FETCH_HEAD fatal: refusing to merge unrelated histories
上网搜索了一下,这是说这是两个不同的仓库,需要添加一句代码(如果你的分支是master)
git pull origin master ----allow-unrelated-histories
然后就完成了。
[本文参考地址](http://blog.csdn.net/lindexi_gd/article/details/52554159)
[欢迎关注我的github,给小白点个star哈~](https://github.com/tjucaokun)