Home > Net >  How could I move all my files and folder to the master branch in GitHub?
How could I move all my files and folder to the master branch in GitHub?

Time:05-29

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:

  1. In the GitHub Desktop client, switch to the master branch.
  2. Go to Branch > Merge into Current Branch.
  3. In the merge window, I select the engineers branch, and here is the problem.

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?

CodePudding user response:

There is no such thing as "moving files to another branch". Branches are not at all the same as folders. Read up on Git basics if this confuses you.

In any case: just delete the master branch, and create a new branch named master off the tip of the engineers branch. They will share history and essentially be the same until you commit to either of them.

On the command line, this would be:

git branch -D master
git checkout engineers
git checkout -b master

CodePudding user response:

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!

  • Related