Git: Fun with subtrees

Before the process of streamlining I’ve had quite a few directories, where git repositories could be found:

On my laptop, those would be ~/projects/repos/open, ~/projects/repos/closed, ~/projects/repos/github and all softlinked to their respective “shortcuts”, as I’d like to call them in ${HOME}: ~/o, ~/c, and ~/gh. My computer at work was even more messier.

Then I’ve decided to streamline everything into one big repository, as I’ve done in the past. Back then I hated the idea of using submodules and I wanted something better, but I never really had the time to dive deeper into git. Now I’ve come around the concept of git subtrees. And that was really all I ever needed. With subtrees it’s as easy as the following four commands to add an existing repository to a subdirectory in your mainline repository:

git remote add blog git@github.com:uleenucks/blog.git
git subtree add --prefix blog blog master
git subtree pull --prefix blog blog master
git subtree push --prefix blog blog master