Hi, I have created a git repository named Animals, In that default branch is main. But I have started developing in master branch and pushed all the changes in master branch.
Now, main branch is empty or it has only ReadMe.md file.
Now, I wants to have everything in main branch whatever present in master branch.
In my terminal, I moved to main repository using "git checkout main" and used "git merge master"
Now, I am facing an issue that Unrelated Histories, what should I do now?
Run this command from your main branch:
git merge master --allow-unrelated-histories
This tells Git:
“Yes, I know these branches don’t share a common ancestor — merge anyway.”
Why This Happens:
- You may have created
mainandmasterseparately (e.g., cloned, then created a new branch). - Git normally expects branches to share a common commit history.
After the Merge:
- Resolve any merge conflicts if prompted.
- Commit the merge.
- Push
mainto remote:
No comments:
Post a Comment