Reputation: 230
I have a GitHub repository that currently only uses the master branch. There are two main directories; "chrome", and "android", for the Chrome app and Android app, respectively. I'd like to move everything inside the "android" directory to a new "chrome" branch, and move everything inside the "android" directory into a new "android" branch. I already have loads of history on all of the files and would like to keep that history in the new branch.
How do I go about doing this? The repo I'm talking about: https://github.com/Gawdl3y/task-timer
Upvotes: 0
Views: 225
Reputation: 2785
If the two folders contain distinct code development, it may be prudent to separate the folders into two separate repositories. This can be done as follows:
cd
into project copygit filter-branch --prune-empty --subdirectory-filter <folder-name>
The history will be retained for the specified folder's files and a repositories with all commits will now be in the root of the "new" versioned project folder.
Note: Where is your "chrome" or "android" directory
Upvotes: 2
Reputation: 2655
create your branches, like this:
git branch chrome
git branch android
then, one by one, manipulate the branches
git checkout chrome
rm -r android/
git commit -a
git checkout android
rm -r chrome
git commit -a
and so on. Even moving files should keep history. good luck!
Upvotes: 2