0

I have the following problem

git pull
fatal: refusing to merge unrelated histories

git pull --allow-unrelated-histories
^@Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

Thus please no --allow-unrelated-histories suggestions. Also, I don't want to merge (or rebase?) anything; the content of remote and locale repo are basically the same. However, git log shows me a completely wrong history, which comes from a submodule. Probably, I somehow screw it up.

Can I some overwrite the locale history with the remote history?

(The local repo has some untracked files, which I want to keep; otherwise I would just clone the remote repo again.)

  • Does this answer your question? [How to overwrite local history with remote?](https://stackoverflow.com/questions/67863536/how-to-overwrite-local-history-with-remote) – Daniel Mann Mar 17 '23 at 21:58

1 Answers1

-1

Ok, I found the solution at https://stackoverflow.com/a/67863703/11769765:

git fetch
git reset --hard origin/main

What did not work:

  • git reset --hard
  • git reset --hard origin/master

Useful commands for inspecting/setting the right repo: git log, git remote show origin, git remote set-url origin ssh://git@....

isherwood
  • 58,414
  • 16
  • 114
  • 157