git学习笔记——push时无法将本地仓库与远程仓库合并

我本地的仓库是通过git init创建的,而远程仓库是直接在gitee创建的,所以这两个仓库是不同的仓库所以当push本地仓库到远程仓库的时候会失败。

解决方法:

# 通过在后面添加以下内容即可忽略这个问题
--allow-unrelated-histories
# 例如:
git pull origin master --allow-unrelated-histories

当由于本地的仓库之前已经有过一次远程的origin时,需要先删除链接:

git remote rm origin

然后按照正常操作就行了

git remote add origin https://gitee.com/xxxxxx.git
git push origin master
posted @ 2023-05-31 10:44  三眠  阅读(65)  评论(0)    收藏  举报