Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging master into main branch

Tags:

git

github

I am attempting these days to have my master branch into my main branch (so I can start using as the default one), however, I am not being able to make it in GitHub.

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.

What can I do to fix it and why does this happen?

like image 765
Thai Rodrigues Avatar asked Dec 26 '20 00:12

Thai Rodrigues


People also ask

Can we merge master into branch?

You can either git merge master or git rebase master . If the branch has not been distributed to other people, in this case i would prefer git rebase. Because git rebase makes it as if the changes on the feature branch were made on top of the changes on the master branch, which makes the version graph simpler.

How do I merge master and main branch in GitHub?

In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.

Does merging master into branch change master?

git merge master will update your current branch with the changes from your local master branch, the state of which will be that of when you last pulled while on that branch.


1 Answers

It is better to follow the "Renaming the default branch from master" official GitHub guide: there will be a native GitHub feature to do that in January 2021.

But if you don't have any pending pull requests, draft releases or branch protection policies, then you can

git switch -c main master
git push -u origin main

(Change the default branch if the remote repository)

git push -d master
git branch -d master
like image 58
VonC Avatar answered Oct 16 '22 19:10

VonC