今天想把電腦上的本地項目經過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