首页 > 解决方案 > git pull: fatal: refusing to merge unrelated histories

问题描述

Description: I have a remote repository with his data. I have a local repository with his data.

I want to clone/pull the data from my remote repo to my local repo without changing the local repo folder structure.

Or I want to push my local repo to my remote repo with the local repo structure without altering the remote repo folder structure. I want to keep my local repo for future pushing.

  1. git init [ok] Output: Initialized empty Git repository in [...]
  2. git add . [ok]
  3. git commit -m "first commit" [ok] Output: 9 files changed, 168 insertions(+) [...]
  4. git remote add origin https://github.com/Mi7ai/Spring.git [ok]
  5. git remote -v [ok] Output: origin https://github.com/Mi7ai/Spring.git (fetch) origin https://github.com/Mi7ai/Spring.git (push)
  6. git push origin master [warning] Output: hint: Updates were rejected because the remote contains work that you do [...]. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again.
  7. git pull origin master [warning] Output: * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories

I have read that --allow unrelated histories is not the right way to do it.

How should I achieve what I want?

OS: Windows 10

Thanks.

标签: gitgithub

解决方案


推荐阅读