Refusing to merge unrelated histories in Git GIT

Refusing to merge unrelated histories in Git

Problem definition

Today, I encountered a problem fatal: refusing to merge unrelated histories while pulling the git repository to my local machine.

The error basically means the current project we are working is unrelated to the repository that we are pulling. This usually happens when:

  1. We already have a git project in your local machine.
  2. We created a repository in remote like GitHub, Bitbucket, GitLab, and so on.
  3. Then you try to pull a repository in your local project.

Let’s fix fatal: refusing to merge unrelated histories

The error can be resolved when you append a parameter --allow-unrelated-histories. Example is below.

Let’s say your remote branch is master then:

git pull origin master --allow-unrelated-histories

Conclusion

The problem we were facing is successfully resolved with the help of --allow-unrelated-histories parameters.

Thanks


Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments