If you need version control for your projects, want to host it yourself, but don’t want to use barebones git, you can set up a Gitlab server to store all of your code while providing easy access through a web interface.

Gitlab Is Like Your Own Hosted Github

Gitlab is a hosted git service that works much like Github, with an interactive web panel for managing your projects and viewing code. If you just want an alternative to Github, you can use their free online service, without setting anything up yourself.

Unlike Github though, Gitlab’s community edition is open source, and free for you to host on your own private server. There are no limitations on project size or project count, which makes this solution great for people with large binary files that are too big for Github’s 100 MB file limit.

Obviously, this requires you to pay for the server, and the storage space for hosting your files. If you’ve already got a server, you can install Gitlab alongside your other processes, but it is fairly resource intensive—Gitlab recommends 4 GB of RAM, and in our testing it used about 2.8 GB. It may be possible to get away with less, but you may run into slowdowns when pushing code. As far as CPU usage goes, Gitlab stayed below around 10% usage in our testing when pushing and pulling large projects.

One thing to note is that if you’re running it yourself, it isn’t a 100% backup. If your instance is terminated, you data can be lost. Really, git itself shouldn’t be used as a backup tool, although it can be used as such with services like Github.

How To Install Gitlab

First, you’ll have to make sure the dependencies for HTTPS are installed— openssh-server and ca-certificates. They likely are already, but if they aren’t, you’ll want to fetch them from your distro’s package manager. For Debian based systems like Ubuntu, that would be:

You’ll also want Postfix installed and configured so Gitlab can send you emails:

This is optional, but nice to have.

Next, you’ll have to add the Gitlab repository:

If you have a different package manager than apt, you’ll need a different script.

Then, you can install Gitlab. You’ll need to pass in your external URL as an argument when running apt-get install. It’s a good idea to put this on a subdomain like git.example.com, so Gitlab won’t interfere with anything else you have running.

Make sure to mark this domain as HTTPS; Gitlab will automatically install and manage certificates from LetsEncrypt for free.

This will take a few minutes to install, but once it’s done, you’ll be kicked back to your standard prompt with a message telling you Gitlab is installed.

At this point, you can disconnect from SSH, as the rest of the setup will be in the browser. Head to your configured URL, and you should see the following welcome screen. This page should be served over HTTPS, with a new certificate for the subdomain.

Enter in a new master password for the Gitlab root account; note that this isn’t your account password, you’ll make an account after this.

Once the password is set, you’ll want to register an account. Since it’s your personal server, you can have any username you want. Feel free to grab the four letter username you always wanted. Put in your email, create the account, and then immediately sign out.

You’ll want to log into the root account and give your personal account admin access. The username will be root, and the password will be the master password you set a few seconds ago. You should now see a wrench icon taking you to the Gitlab instance settings:

From here, you can modify your instance’s settings, such as configuring your site title and icon. You can also manage users and lock down account creation if you prefer. From the “users” tab though, you can promote your personal account to administrator, and log out of the root account.

From here, you should have full access to Gitlab. If you’re collaborating on code, you can make a new group, and create a project under that group (rather than under your username).

Once your project is created, you can connect it with your local Git as you normally would. Make sure to add your SSH keys in your account settings, so you can push without entering your password every time.