- There are multiple services, which allows hosting Git repositories online.
- Out of these services Gogs is a lightweight and self-hosted solution.
- Online repository hosting using Gogs is very easy.
- Gogs are written in ‘Go’ and it requires much less hardware compared to Gitlab.
- It provides easiest, fastest and most painless way of setting up a self-hosted Git service.
- If a user is familiar with GitHub, then it is easy to understand Gogs.
- Gogs support all platform like Linux, Windows, macOS etc
- Before installation user will need to set up a system. To install Gogs, a user should install Git, SSH server and a database such as MySQL or PostgreSQL.
- In this guide, we will be installing MySQL and Git on CentOS.
- Run command to update system
- Setup hostname for a server, it will be easy to identify.
MySQL and GIT installation and configuration
- The following command will add MySQL repository on server
- Install MySQL using the following command
- Add a Gogs user and set home directory for Gogs user
Configuring the Database
- If a user on Ubuntu, the database server will be auto-started at the time of installation.
- However, with CentOS/RHEL, you will need to start it up manually. You will also have to “enable” it so that MySQL starts up whenever your system boots up.
- To do so, run the following command
- During installation, the root user of MySQL is assigned a random password in CentOS. To get that password run the following command
- Run the following command to secure MySQL installation
(User will be asked for your MySQL root password. Enter your temporary password. Once logged in, change the password for root user. You will be prompted with few more questions. Recommended is that you answer ‘y’ for all questions.)
- Now try to login to the MySQL console as a root user
- Create user in MySQL
- Create a database ‘gogs’ and allow new user to work on that database
(Note down database name, user and password – user will need them.)
Install and configure Gogs
- There are two ways to install Gogs:
- Install from Binary.
- Install from Source.
- In this guide, we are going to install Gogs using Binary.
- To download specific release follow this link https://github.com/gogits/gogs/releases
- Extract the downloaded archive
- Now go to extracted directory and execute the following command
- User can start Gogs using following command
- For on-boot start service use enable command
- Now go to http://localhost:3000, it will open installation page, In that user have to provide the mandatory details and login.
Figure: Gogs UI configuration
Hence Gogs is proven to be the easiest way to handle git repositories for user projects. It is an open source project which has active community support. With Gogs, a user can perform any tasks which can be done via git. So go ahead and try it out.