I have a GitHub repository with 2 Branches: master , engineers. All my files and folders are in engineers branch. The master branch is empty.
I downloaded the GitHub Desktop, login using my GitHub account, then clone the project.
Now, I want to move everything in engineers branch to master branch. I follow different tutorials to merge them using GitHub Desktop. Here what I did:
I cannot do merge because I got this message 'Unable to merge unrelated history in this repository. '
I am new to GitHub, what is the problem? What I missed? how could I move all my files and folder to the master branch?
Remove your current master
branch and then create it new from the engineers
branch, so that you then have two branches with an identical status.
First step:
git checkout engineers
Then delete the old master
branch with:
git branch -D master
Now, you have just one branch, which is named engineers
. Now you can create from there a new branch with:
git branch master
And then navigate to this new branch:
git checkout master
You can also do this in one command:
git checkout -b master
Now you have your goal: a master
branch with all the current files and changes as the engineers
branch.
But be aware (like @Thomas said), the "move files" activity does not exist in Git. In Git you have ONE main-branch (master
, main
or sometimes develop
/dev
) and from there you create new branches and add the code/file changes from these branches (they are also called feature-branches, in gitflow) into the main
branch with PR's or merges.
I recommend you to look at the literature to understand it!