Self-hosted Git repositories provide a secure and flexible solution for managing your codebase. Gitea, a lightweight Git service, offers a user-friendly interface and powerful features. In this setup guide, we will walk you through the process of setting up self-hosted Git repositories using Gitea.


Before we begin, make sure you have the following:

  • Linux server or VPS
  • Root access to the server
  • Domain name (optional, but recommended)

Step 1: Install Gitea

To start, we need to install Gitea on our server. Follow these steps:

  1. Connect to your server via SSH.
  2. Create a new system user for Gitea:
$ sudo adduser --system --shell /bin/bash --gecos 'Gitea' --group --disabled-password --home /home/git git
  1. Download the latest Gitea release:
$ wget
  1. Rename the downloaded file:
$ mv gitea-1.15.4-linux-amd64 gitea
  1. Make the Gitea binary executable:
$ chmod +x gitea
  1. Move the Gitea binary to the system’s binary directory:
$ sudo mv gitea /usr/local/bin/
  1. Create a new directory for Gitea’s data:
$ sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
  1. Set the ownership of the data directory to the Gitea user:
$ sudo chown -R git:git /var/lib/gitea/{data,indexers,log}
  1. Set the permissions of the data directory:
$ sudo chmod -R 750 /var/lib/gitea/{data,indexers,log}
  1. Create a new systemd service file for Gitea:
$ sudo nano /etc/systemd/system/gitea.service

Add the following content to the file:

Description=Gitea (Git with a cup of tea)

# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

  1. Reload systemd and start Gitea:
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now gitea

Step 2: Configure Gitea

Now that Gitea is installed, we need to configure it. Follow these steps:

  1. Open your web browser and navigate to your server’s IP address or domain name.
  2. Complete the initial setup by providing the necessary information, such as the database settings and administrator account details.
  3. Once the setup is complete, you will be redirected to the Gitea dashboard.

Step 3: Create a New Repository

With Gitea configured, you can now create a new repository. Follow these steps:

  1. Click on the “New Repository” button on the Gitea dashboard.
  2. Provide a name and description for your repository.
  3. Choose the visibility settings (public or private).
  4. Click on the “Create Repository” button to create the repository.

Step 4: Clone and Push to the Repository

To start using your repository, you need to clone it to your local machine and push your code. Follow these steps:

  1. Copy the repository URL from the Gitea repository page.
  2. Open your terminal and navigate to the directory where you want to clone the repository.
  3. Run the following command to clone the repository:
$ git clone [repository URL]
  1. Navigate to the cloned repository:
$ cd [repository name]
  1. Add your code files to the repository.
  2. Commit your changes:
$ git commit -m "Initial commit"
  1. Push your code to the repository:
$ git push origin master


1. Can I use Gitea on Windows?

Yes, Gitea can be installed and used on Windows. However, it is more commonly used on Linux servers for self-hosted Git repositories.

2. Can I use an existing database for Gitea?

Yes, Gitea supports various databases such as MySQL, PostgreSQL, and SQLite. During the initial setup, you can provide the necessary database settings to connect to an existing database.

3. Can I customize the appearance of Gitea?

Yes, Gitea allows you to customize the appearance by modifying the CSS and templates. You can also choose from different themes available in the Gitea community.


Congratulations! You have successfully set up self-hosted Git repositories using Gitea. You can now manage your codebase efficiently and collaborate with your team. Enjoy the benefits of self-hosted Git repositories and take your development workflow to the next level.

For more information and advanced configurations, refer to the official Gitea documentation.