1. Introduction

Git, a distributed version control tool, has been one of the preferred versions of modern software source code. Public Git service providers such as GitHub have high network latency in China, and Gitlab is suspected of discriminating against China. Gitee and Coding are not bad in Korea. However, corporate source code will not be placed on public Git services unless it is an open source project. Therefore, we need a self-managed Git service program that is easy to install, easy to get started, and has low hardware requirements. Of course, it would be better if it were free. A tool that meets these requirements is recommended today ———— Gitea.

2. Gitea

Gitea is an open source community-driven lightweight code hosting solution with a back end written in Go under the MIT license. It is a fork of Gogs, another open source Git service solution. Compared to Gogs, it has more features, a more active community, and faster version iteration. Gogs is also a good option if you’re a small, simple team. If your team is likely to have a larger size, Gitea may be more suitable for you.

3. Characteristics of Gitea

  • All the source code is open source and you can find it on GitHub. Those with development ability can carry out secondary development.
  • Easy installation Multiple installation methods are available. Binary install or use Docker, Vagrant, and install packages.
  • Cross-platform runs on any platform that Go can compile on: Windows, macOS, Linux, ARM, etc. Pick your favorite!
  • Lightweight and low system requirements, even raspberry PI can run, saving machine resources! Unlike Gitlab, which has a high resource footprint.

In fact, another point is that the document is more friendly to Chinese people. Chinese documentation is also relatively complete.

4. Install Gitea on Windows

Let’s show you how to install Gitea under Windows. Other platforms can refer to the above Chinese documents for installation.

4.1 download

We select the platform and version you need from the download portal. Here we select the.exe installation package for Windows 1.95.

4.2 installation

Please note: If you want to install to a certain path, please copy the downloaded installation package to the path and double-click install. Remember that!

Copy the installation package gitEA-1.9.5-Windows-4.0-386. exe to the path I intend to install C:gitea. Double-click the installation package and the following interface will appear:

We are prompted to listen to the path The following interface appears when you open http://localhost:3000/ :

Click the register button in the upper right corner and the form page for initial configuration will be displayed. What we are looking at here is the database setup. Gitea requires MySQL, PostgreSQL, MSSQL, or SQLite3. The database is not included in the installation package! . So you need to configure the database environment in advance, and then fill in the configuration. Other configurations are based on your own personalized needs to select a line to fill in submit. A short period of time is required to wait for database initialization. After initialization, the home page is displayed:

Git installation is complete, and the public Git service usage is almost the same, are interface operation.

4.3 Running as a Windows service

With the above setup, the Gitea service is closed each time CMD is closed. Every time I have to start it through Gaitea-1.9.5-Windows-4.0-386.exe, which is very inconvenient. Registering as a Windows service is much easier.

To register as a Windows service, first run CMD as Administrator and then run the following command:

 sc create gitea start= auto binPath= ""C:\gitea\gitea.exe" web --config "C:\gitea\custom\conf\app.ini""Copy the code

Don’t forget to replace C:gitea with your Gitea installation directory.

Then open Windows Services in the control panel, search gitea, right-click and select Run. Visit http://localhost:3000 in your browser. (If you have changed the port, please visit the corresponding port, 3000 is the default port). You can also set it to boot.

Run CMD as Administrator and then run the following command to remove Gitea from the Windows service:

 sc delete giteaCopy the code

5. To summarize

Today, I briefly covered how to build a private Git service using Gitea. More advanced operations can be learned through official documentation. In comparison, using Gitea is cheaper and a good choice.

Follow our public id: Felordcn for more information

Personal blog: https://felord.cn