I have a git repo with several subdirectories in its root, for example
repo<master>/a/files
repo<master>/b/files
...
I would like to move each subdirectory out of the master branch and into it's own branch, and move the files up one directory in the process, so that I'm left with something like this.
repo<branch_a>/files
repo<branch_b>/files
...
I have a few ideas of how to do it, for example:
Is there anyway I can do this more efficiently, i.e. less deletes but still maintain revision history?
This question is similar to Detach (move) subdirectory into separate Git repository but instead of moving each subdirectory into a separate repository I want to move it into its own branch.
Here's a moderately concise approach:
master
, each in an individual commitmaster
Pseudobash:
$ for dir in one two three; do git rm -r $dir; git commit -m "Remove $dir"; done
$ git log # For commit SHAs
$ git checkout -b one
$ git revert $sha_that_removed_one
$ git mv one/* .
$ git commit -m "Move one files to the top level"