git提交本地项目报错

此次我是想把写好的做业上传到github上,git

  • 首先我在github上面新建了一个repository
  • 又在本地 git init创建了一个git仓库
  • 而后在git add commit后,使用命令
git remote add origin 远程仓库地址

没有消息。。。而后我就想起我老师说,没有消息就是好消息,而后我就想上传代码github

git push -u origin master

发现报错了 ,报的是fetch

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一下,而后他又报了错.net

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)code

git pull origin master ----allow-unrelated-histories

而后就完成了。blog

[本文参考地址](http://blog.csdn.net/lindexi_gd/article/details/52554159)

 [欢迎关注个人github,给小白点个star哈~](https://github.com/tjucaokun)
相关文章
相关标签/搜索