So, I\'ve a bigger (closed source) project, and in the context of this project created a library which could also be useful elsewhere, I think.
I now want to split o
This seems to be a common request, however I don't think there's a simple answer, when the folders are mixed together like that.
The general method I suggest to split out the library mixed in with other folders is this:
Make a branch with the new root for the library:
git subtree split -P src/de/fencing_game -b temp-br
git checkout temp-br
# -or-, if you really want to keep the full path:
git checkout -b temp-br
cd src/de/fencing_game
Then use something to re-write history to remove the parts that aren't part of the library. I'm not expert on this but I was able to experiment and found something like this to work:
git filter-branch --tag-name-filter cat --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch client server otherstuff' HEAD
# also clear out stuff from the sub dir
cd transport
git filter-branch --tag-name-filter cat --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch fencing client server' HEAD
Note: You might need to delete the back-up made by filter-branch between successive commands.
git update-ref -d refs/original/refs/heads/temp-br
Lastly, just create a new repo for the library and pull in everything that's left:
cd
git init
git pull temp-br
I recommend that your final library path be more like /transport/protocol
instead of the full parent project path since that seems kind of tied to the project.