本地项目添加远程仓库:

$ git remote add new_origin https://github.com/user/repo.git
# Set a new remote

$ git remote -v
# Verify new remote
> new_origin  https://github.com/user/repo.git (fetch)
> new_origin  https://github.com/user/repo.git (push)

上面new_origin就是远程仓库的别名,随便取。因为仓库在创建时会生成一个readme文件,所以我要在本地先同步下代码:

git pull new_origin master

这时就会报如下错误:

From https://github.com/user/repo
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

默认情况下,git认为这是两个不同的项目,没有关联所以禁止合并,解决办法就是在后面加上--allow-unrelated-histories

git pull new_origin master --allow-unrelated-histories

这样就成功了。


参考:

相关文章:

  • 2022-01-29
  • 2021-08-11
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-06-10
猜你喜欢
  • 2022-12-23
  • 2021-04-16
  • 2021-10-22
  • 2022-12-23
  • 2021-08-29
  • 2021-11-21
  • 2021-08-11
相关资源
相似解决方案