Git提交遇到non-fast-forward

今天想把電腦上的本地項目經過Git提交到Coding上面,在Coding上建立項目、初始化倉庫並自動建立了README.md文件,而後本地提交時執行git push的時候,提示:git

To https://git.coding.net/xxxx/xxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.coding.net/xxxx/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

提示push失敗,在push執行須要執行pull拉取遠程代碼。而後執行git pull origin master.net

From https://git.coding.net/xxxx/xxx
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

意思是拒絕合併無聯繫的歷史,代表本地和遠程如今是兩個不一樣的項目。code

解決方案(使用其中一種便可)
針對refusing to merge unrelated histories問題ip

#容許合併不相關的內容
$ git pull --allow-unrelated-histories

#提交內容
$ git push

針對non-fast-forward問題rem

#強推,本地代碼強行覆蓋遠程`git`倉庫
$ git push -f
相關文章
相關標籤/搜索