Consider hosting your own git repositories

Posted in: main (1 min read)

In the light of the recent events, a lot of people are searching for alternatives to GitHub.

Hosting your own git repos is not as hard as people may imagine and maybe you should consider that as an option.

It boils down to this:

  1. If you don't already have a Linux/BSD VPS, consider getting one (it'll be useful for a lot more than this)

  2. Make sure that you have git installed (i.e. apt/yum install git)

  3. Make a directory and do git --bare init there

Congrats - you can now easily access your new repo over ssh:

git clone ssh://myhost/mydir

It may be also worth mentioning that now you have full access to things like git hooks (from which you have direct access to your whole system - this can be pretty useful).

Next steps

For private repos, you don't need much more than this.

Making your repositories publically available is also not hard - there are many ways, the simplest one is probably to just pass HTTP requests from your web server (e.g. nginx) to git-http-backend (I'll create a separate post for this).

Note: If you're new to all this, you may want to experiment in local VMs before you're comfortable with managing a real VPS.


Comments, suggestions, and questions are welcome.