19 lines
636 B
Markdown
19 lines
636 B
Markdown
---
|
|
title: git远程仓库与本地建立联系失败refusing to merge unrelated histories
|
|
createTime: 2023/07/06 22:47:16
|
|
tags:
|
|
- git
|
|
---
|
|
|
|
通常会出现在远端仓库有文件、本地仓库也有文件的时候,是因为这两个仓库在 sync 之前根本没有建立起来联系
|
|
|
|
## 解决方法 1
|
|
|
|
先`git clone`远端仓库,然后把本地文件移动到下载的远端仓库中,再提交上去,相当于进行了一次对远端仓库的 commit
|
|
|
|
## 解决方法 2
|
|
|
|
强制合并:`git pull origin master --allow-unrelated-histories`
|
|
|
|
然后解决 conflict 再 push 回去,`git push origin local_main:remote_main`
|