Where's the conventional place to store git repositories in a linux file system tree?

There is no right or wrong answer here, except the one dictated by your own personal religion and the contents of the hier(7) manpage on your system.

typical Linux hier manpage ; typical BSD hier manpage)

/var/git/* seems reasonable to me personally. That's where I keep mine.


Place it in a directory (or shared filesystem) under /srv. This is what it's for.

The /srv directory is intended for site-specific data served by the system. From the standard:

This main purpose of specifying this is so that users may find the location of the data files for particular service, and so that services which require a single tree for readonly data, writable data and scripts (such as cgi scripts) can be reasonably placed. Data that is only of interest to a specific user should go in that users' home directory.

The methodology used to name subdirectories of /srv is unspecified as there is currently no consensus on how this should be done. One method for structuring data under /srv is by protocol, eg. ftp, rsync, www, and cvs. On large systems it can be useful to structure /srv by administrative context, such as /srv/physics/www, /srv/compsci/cvs, etc. This setup will differ from host to host. Therefore, no program should rely on a specific subdirectory structure of /srv existing or data necessarily being stored in /srv. However /srv should always exist on FHS compliant systems and should be used as the default location for such data.

Distributions must take care not to remove locally placed files in these directories without administrator permission.


On an SELinux-enabled system, the default directory is /var/www/git, and repos should be in subdirectories thereof. Or, you can use, e.g. /srv/git and set the file context to be equivalent:

semanage fcontext -a -e /var/www/git /srv/git

/home/git/

This might seem a bit unconventional at first but it is very reasonable as this directory is made for you (with correct permissions) when you do sudo useradd git. You can just switch to the git user, cd and immediately run:

$ mkdir .ssh; chmod 700 .ssh
$ touch .ssh/authorized_keys; chmod 600 .ssh/authorized_keys

and put public keys of your peers into the just created authorized_keys file.

After you git init --bare your project, the "url" is then just...wait for it...

git@<server>:<project>

As voretaq7 said, there is no right or wrong answer on such a subject. However, if you want to follow of softs, it seems that database softs store their data in

/var/lib/soft

For example, for Postgresql 9.1 on debian the folder is

/var/lib/postgresql/9.1/

So I would personnaly choose

/var/lib/git

On my Arch Linux I have /srv/http for apache (which is system default) and I use it for my node.js http servers too. Similarly I decided to just put all git repositories in /srv/git.

I use GitLab, and /srv/git is the home folder for git in that case too.

Ultimately, it's up to you. I found that sticking to a format similar to other services in your distro is easy to remember.