Roy O'Bannon
Roy O'Bannon

Reputation: 326

Two branches pull request yeilds entirely different commit histories

I cloned a repo to my computer:

git clone <repo>

Then I created a new repo on Github.

In my cloned repo I assigned a remote origin:

git remote <new repo>

I got two branches: main (marked as 'default' on Github) and master.

I started working with master. Everything was fine, I could even 'push' my changes. But when I tried to create a pull request to merge master into main.

I didn't get a PR button and got the notification that

There isn’t anything to compare.

main and master are entirely different commit histories.

I tried to find a solution, but because of my lack of experience with Git I can't decide if one of them fits in to my problem. Here are many [examples][1].

How can I merge my changes from master into main?

Upvotes: 1

Views: 1448

Answers (1)

user229044
user229044

Reputation: 239311

If you're receiving this error for a newly created Github repo, it's likely that you added files to your default main branch during project creation, for example a README.md.

Your local master branch will indeed have no shared history with your remote main branch, and you cannot create pull requests from one to the other.

To fix this, you need to check fetch your main branch locally and then rebase your master branch on top of it, so that it shares main's history:

git fetch
git checkout master
git rebase origin/main

Upvotes: 3

Related Questions