How to merge master branch into main


I have created a new remote repo "infrastructure" on GitHub.

I have then created a local repo on my computer in the folder "infr" with git init

When I pushed my local repo with git push -u origin master the new branch "master" was created.

I want to merge "master" branch into "main" branch now.

After trying to open a pull request git does not detect differences between them and does not let me do the merging, although checking each branch, you can see all files from my project in the master and nothing in the main.

I have tried renaming my "master" branch into "main" but I got an error : "Could not rename branch "master" at this time: New branch already exists".

So how do I merge master into main branch ?


I encountered same problem 4 days ago and what I have done is I opened my online repo in git site and went into repo settings and clicked on branches option. I changed the default branch from main to master and i later deleted the main branch as it was empty. tell me if this works for you. github repo settings

Answered By – sravanTG

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published