I would like to split on folder from my git repository into new one. But I would like to keep all open/closed branches and history for everything related to this folder.
\ Source Repo
--\ AAA
--\ BBB
----\ DDD
----\ EEE
--\ CCC
\ New Repo 1
--\ AAA
--\ CCC
\ New Repo 2 (BBB subfolder)
--\ DDD
--\ EEE
I followed steps described here https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/ - but this work only for a single branch. At the end - I get new repository with all (?) commits but no branch information is present.
I tried to do this for all branches using --all
parameter, but I'm not clear how to push all rewritten branches to the empty remote repo.
Here is what I have currently:
$ git clone https://github.com/USERNAME/REPOSITORY-NAME
$ cd REPOSITORY-NAME
$ git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME -- --all
At this point if I look at my local repo, I seem to have all history and all branches in remotes origins.
$ git remote -v
origin https://github.com/USERNAME/REPOSITORY-NAME.git (fetch)
origin https://github.com/USERNAME/REPOSITORY-NAME.git (push)
$ git remote set-url origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git
$ git remote -v
origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (fetch)
origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (push)
$ git push -u origin --all
Last command doesn't seem to be pushing all branches. What am I missing?