Git repos organisation ideas

Just a quick post about ways to organise code repositories on your computer (based on my personal experiences) depending on your situation.

When working for a web agency

If you work for many years at the same web agency, you will probably clone dozens of repositories on your computer. Some may come from github, bitbucket, some may be owned by the agency or by the client. It may even be an internal repository your colleague shares with you. Sometimes many repos may have the same name. Sometime you have to fork an open source repo to do a pull request. Sometimes the agency may have it's own custom forks.

If you don't adopt an "overkill" structure, things may become messy over time. To make sure this does not happen, I came up with this structure :

~/repos
    /github
        /agency-a
            /project-1
            /project-2
        /client-a
            /project-3
        /vuejs
            /vue
            /vue-router
    /bitbucket
        /client-b
            /project-4
        /wmcmurray
            /my-personal-blog

Basically, everything is in a /repos directory inside my user directory. The next layer is the platform on which the repository reside (github, bitbucket, etc). After that, I create a directory with the username of the owner of the repo on that platform. And then all the repos of that user.

I never had conflicts using this structure. It may be a pain to navigate between projects in the console tho, so I made myself a bunch of aliases to navigate quickly between them.

When working for a startup

When working for a startup, things have more chances to change. If the company have only one repo, maybe in two week you'll divide that into multiple repos, maybe open source some of them ? Maybe switch to github instead of bitbucket ? Maybe you'll not work there anymore in two weeks ?

You could structure your repos like this :

~/repos
    /startup-a
        /website
        /internal-tools
    /startup-b
        /website
    /personal
    /forks

This way your personal repos and open-source-related-contributions won't be affected by what happens in the startup(s) you work for.

When working for an older company

In an older company, things have settled down more and things won't change as quickly as in a startup. So if the entire company's ecosystem reside inside one repo, you could simply go for :

~/repos
    /company-website
    /personal-project-a
    /personal-project-b
    /fork-a
    /fork-b

Everything is in one directory and is quickly accessible. Sometimes it is sufficient !