Search code examples
gitrepositorymove

Transferring git files to another branch


I have some Android device source code uploaded to a git repository. The code is currently on the master branch. I want to add a different Android source code (different android version) in the same repo, but on a different branch. But, I want to categorize each source tree in its own branch.

So, what I want to do is:

  1. Create new branch called cm10
  2. Move all the code from master branch to cm10 branch
  3. Completely delete the master branch

I am new to git, so I can only easily create a new branch (new branch called cm10 in this case), but I don't know how to do the rest.

Please also add comments on what each command does. It will be a good way for me learn more about git.


Solution

  • I better dont ask why you wanna do this...

    git checkout -b cm10 // checkout cm10 branch (-b creates it)
    git merge master // shoud not be neccessary when branch is created
    git branch -d master // delete the master branch
    
    // if you have remote repository too you may want to:
    git push origin cm10 // create new remote branch
    git push origin :master // remove master branch