Achim Mertens avatar

How To Merge Master And Main Branch In Github With Eclipse

achimmertens

Published: 09 Nov 2021 › Updated: 09 Nov 2021How To Merge Master And Main Branch In Github With Eclipse

How To Merge Master And Main Branch In Github With Eclipse

Hello,

here I describe how I merged two new and different branches in my github repository "Hamurabi".

The Problem

I have created a main branch by default.
But my code was uploaded into the "Master" branch.
Now I want to merge both, but I get a error message on github, when I try a merge request:
"main and master are entirely different commit histories."

This is what worked out:

In Eclipse, do your changes in the branch that you want to keep, commit them and then click on "push HEAD".
In the following dialog choose a different branch. Check "Force overwrite branch in remote if it exists and has diverged". Be aware that it deletes all files in the target branch. (Maybe you copy some needed files from target to source branch before):

I repeated this for the branch "Develop".

After that I was able to merge both (master and Develop) branches:

Regards, Achim

Leave How To Merge Master And Main Branch In Github With Eclipse to:

Written by

Love also your next but one and create more than you destroy.

Read more #programming posts


Best Posts From Achim Mertens

We have not curated any of achimmertens's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Achim Mertens