問題:
1、本地初始化了git倉庫,放了一些文件進(jìn)去并進(jìn)行了add操作和commit提交操作;
2、github創(chuàng)建了git倉庫并建立了README,.gitignore等文件;
3、本地倉庫添加了github上的git倉庫作為遠(yuǎn)程倉庫,起名origin;
??????git remote add origin 遠(yuǎn)程倉庫地址
4,本地倉庫也遠(yuǎn)程倉庫關(guān)聯(lián)
git branch --set-upstream-to=origin/master master
這個(gè)時(shí)候就出現(xiàn)了
解決問題:
如果直接pull,就會出現(xiàn)??
refusing to merge unrelated histories ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
的錯(cuò)誤,正確姿勢:
git pull origin master --allow-unrelated-histories ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
然后本地遠(yuǎn)程倉庫關(guān)聯(lián)
git branch --set-upstream-to=origin/master master ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
最后就可以push了;
總結(jié)一下:本地倉庫有文件,遠(yuǎn)程倉庫也有文件,正確姿勢:
1,git remote add origin 遠(yuǎn)程倉庫地址
2,git pull origin master --allow-unrelated-histories
3,git branch --set-upstream-to=origin/master master
4,git push
————————————————
版權(quán)聲明:本文為CSDN博主「且聽風(fēng)吟9826」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_28474017/java/article/details/98959779