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)
相關文章
相關標籤/搜索