240
世界上有2种人,一种懂二进制,另一种不懂二进制。

关于git-拉取代码时的问题

问题

第一次拉取时.本地创建对应名称的仓库时出现fatal: refusing to merge unrelated histories 如何解决?

解决

方法一:创建一个新的本地仓库并且不保留历史记录

  1. 首先,在本地创建一个新的空文件夹(仓库):
    git init
  1. 添加远程仓库地址:
    git remote add origin remote_repo_url
  1. 拉取远程仓库的代码:
    git pull origin master --allow-unrelated-histories

这里我们省略了 --allow-unrelated-histories 选项,因为它可能不适用于较旧的 Git 版本,但是在这种情况下,你可能会收到一个警告,但不会导致合并失败。

方法二:创建一个新的本地仓库,手动合并代码
/......

posted @ 2023-07-24 14:57  _Origin  阅读(44)  评论(0)    收藏  举报