I am aware there are nice options to host even for free your private Git repositories (Bitbucket is the nicest example in my opinion), but I really wanted to self-host my private projects, so I looked into that.

I was one of the early adopters of Raspberry PI(I even got a free T-shirt! :-)), I tried several ideas for that 256MB ARM computer, but most of them needed more power or more memory, so finally I ended up installing something cool but useless to me.

After a reinstallation in my main server, I decided to give it a try as a git self-hosted repository, It turned out to be a nice idea!

I installed Raspbian as OS for the PI, I use ArchLinux for my every day work, but I had some problems with data corruption in the PI using ArchLinuxARM, so I gave Raspbian a try and It turned out to work just fine (those data corruptions were probably my fault though).

For git repository management I opted for Gogs, a very nice self-hosted Git service written in Go. It was actually very easy to install and configure, It supports different DBs and caching systems which makes it very reliable and flexible. It also have nice features such as issues and the interface is very similar to Github.

Having my private repositories in Bitbucket I found the New migration button very useful, which you could use to migrate a repository on Bitbucket/Github just giving the url(not the git repo url but the Bitbucket view url, for example https://bitbucket.org/javaguirre/example), It worked flawlessly for me.

The storage is outside the SD card, I mount a external drive as the repository directory with permissions for the user where gogs is (pi or gogs if you created a user just for this service), so in case something goes wrong with the SD card or the system, I just remove the drive and I have all the repositories.

To install Gogs in the Raspberry PI is easy, you just download the ARM build(or you could build it yourself from source). Here you have the installation process well documented, If you have any questions about installation on the PI just let me know!

Once you have it configured and running (I usually use supervisor to handle the running processes, but in this case I just executed it inside tmux and detached it from my tty), you could use NGINX to serve it, this is a simple configuration for doing that, you could start from here:

server {
    listen 80;
    server_name git.taikoa.net;
    
    location / {
        # The port were gogs is running :-)
        proxy_pass http://localhost:3000;
    }
}

These are the stats of my Raspberry running now, using 69MB out of 183MB: