fatal: refusing to merge unrelated histories
TL;DRGit refuses to combine changes from two branches or repositories because they have no shared starting point in their history.
Most likely cause: Attempting to merge or pull from a branch or repo initialized separately without common commits
Try first: Check current branch and status (git status)
Likely causes
- Attempting to merge or pull from a branch or repo initialized separately without common commitsmost likely
- Using git pull or merge after cloning or initializing in a way that creates independent historiespossible
How to fix it
Safest first: SafeChanges settingsDangerous
Check current branch and statusSafe
View the active branch and any pending changes before proceeding.
git statusMerge with unrelated histories flagChanges settings
Allow the merge by explicitly permitting unrelated histories. This modifies your repository.
git merge --allow-unrelated-histories <branch-name>⚠ Back up your repository first as this can alter commit history.
If that didn't fix it
The merge command will keep failing until histories are linked or the allow flag is used.
When to see a technician
Consult a version control specialist if the repository contains critical data and you are unsure about Git operations.
Related errors
codefatal: unable to access 'https://github.com/example/repo.git/': Could not resolve host: github.comcodeCONFLICT (content): Merge conflict in src/app.js | Automatic merge failed; fix conflicts and then commit the result.codeerror: Your local changes to the following files would be overwritten by merge: Please commit your changes or stash themcodefatal: Authentication failed for 'https://github.com/user/repo.git/'codefatal: not a git repository (or any of the parent directories): .gitcodePermission denied (publickey). fatal: Could not read from remote repository.