The Master Submits a PR to Main Branch and appears:There Isn’t Anything To Compare

Question

When the master branch submits a PR to the main branch and appears: There isn't anything to compare.main and master are entirely different commit histories.

Solution

The following operations will forcibly overwrite the original code, so you need to save the content you want to keep in advance, and then manually update it after overwriting.

git checkout master
git branch main master -f
git checkout main
git push origin main -f

Why can't I merge?

After git checkout main, you will be prompted to perform git pull. The test found that the merge failed. The prompt: fatal: refusing to merge unrelated histories, which should mean that master is not allowed to submit PR to the main branch. There is no same associated record, even if the code is similar.

Delete unwanted branches

Delete the local master branch

git branch -D master

Delete remote master branch

git push origin --delete master

Reference

Comments