This will be one of the more technical posts and I really think this could help someone else.
I think it is a very normal situtation to be in: you have grown out of your one repository to rule them all.
And you know that you are not google.
This post will explain moving a folder from one git repository to another and the amazing tool: git filter-branch.
I had a pretty interesting task the other day, namely moving a folder from one git repository to another.
The folder was ready to live by it self as it had grown its own eco system with a complete test suite and did not have any ties to the main repository.
There were just one condition: We did not want to lose the history regarding all the files in this folder.
I got the task of figuring out how we could move the content and history and luckily for me I am not the first one try to tackle this problem.
I pieced the gist below together from various blogs and stackoverflow posts but this stackoverflow post helped me the most.
Enough rambling, lets look at some git commands.
To the git commands
Here be dragons!
I think git is an amazing tool and you should be able to do this kinda crazy thing as well, but please be careful!
The interesting part in the gist above is:
git filter-branch --subdirectory-filter node/ -- --all
Which can actually do the one thing we normally do not like in Configuration Management: rewrite history.
However, in our case it is actually what we want, rewriting the git history that is, because it will trim the repository to only contain the content and history of our node/ folder.
However, please be careful when using
git filter-branch as it will infact rewrite history and if you push it to your master branch on the wrong repository your gonna have to revert.
Hope this helped you out in your git endeavors.