I have a few repositories that I don’t want to share with the world or even GitHub, BitBucket or GitLab. Not because they contain top-secret information, but because I believe that we should store and pay for our own data instead of spreading it over dosen of different could platforms.

If you have a private server with ssh access, then this is an easy task. You don’t need any special software or web-gui, but just git and ssh.

  1. Login to your server and run:

    $ git init --bare my-repo.git
  2. Locally clone the repo as:

    $ git clone address-of-my-server:my-repo.git


Step 1. will create a directory containing your repo on the server. It is identical to the .git directory you are used from your local repositories. The --bare flag instructs git to store just the .git directory without checking out any branches. This is important because you cannot push to a checked-out branch.

Step 2. will ssh to your server and clone the repo. If you don’t use ssh keys, it will also ask you for password. The part after the : is actually a path of the repo relative to home directory on the server.

I store my repos in ~/repos/ (duh!) directory, so I would use:

$ git clone murerzen.eu:repos/my-repo.git

Another thing that you may want to do, is create a separate user (i.e. git) who has the repos it their home directory. In this case, you would use:

$ git clone git@address-of-your-server:my-repo.git

Take them public

If you would want to make the repos public, you can sym-link the my-repo.git directory to the html root of your HTTP server (usually /var/www/html). If you use docker containers, that would mean mounting the directory as a host volume.

This would make the repo accessible as:

$ git clone http://address-of-your-server/my-repo.git

Unfortunatley, there would be no browser-friendly page to see there. For that you would have to turn to gitweb (only basic interface) or Gitea (an opensource clone of GitHub).

Git used as intended

When I figured this out, I was amazed how basic and intuitive this feels. No clicking on a web interface, generating a README file, registration and such. Just the thing, you actually want to do: git init.

And it’s faster too (especially if the server is your basement)!