Migrating from Gitea to Forgejo

2025-01-08

Table of Contents:

Gitea's problem

Gitea is a selfhosted FOSS git forge platform, that I started using from around 2022 to host my code.

However, around one year ago, the Gitea project was overtaken by the Gitea company, with the original project lead as CEO.

I'm personally fine with FOSS software having a company backing, however, the takeover didn't have any community consensus or even previous notice, resulting in confusion leading to community backlashes. [1]

By the way, the CEO responded with a generic answer (We will still open core our software [2]) without addressing any of the issues in the open letter, which sucks and basically breaks the trust on them.

Since I only use it to store some of my personal repos, and no other interactions are involved, I only noticed this around one week ago. Upon noticing, I made clear that I can't continue supporting Gitea in any way, so a change in git forge is needed.

Forgejo

Intro

Installation

Install forgejo according to official wiki. Since I'm on debian, I found their community apt packages at forgejo-contrib[3].

Migration

Forgejo should be a drop-in replacement, however, for my case, I am planning to simplify the stuff by changing DB to sqlite, so we have to migrate the repos manually.

After installation, make sure forgejo is stopped first, since the port and data may conflict.

Clone the git repositories manually from the Gitea instance

Now you can stop your Gitea service.

Then, enable push to create on your forgejo instance:

[repository]
ENABLE_PUSH_CREATE_USER = true
ENABLE_PUSH_CREATE_ORG = true

restart the service: systemctl restart forgejo

Run a bash loop to set the git remote URL to the new push address.

# Old: gitea@git.juancord.xyz:root/stuff.git
# New: forgejo@git.juancord.xyz:root/stuff.git
for i in *; do
 git -C $i remote set-url origin $(git -C $i remote get-url origin | sed "s/gitea/forgejo/")
 git -C $i push --all
done

Verify forgejo works (remember to enable it also), and uninstall gitea

apt purge gitea
systemctl restart forgejo

The last step is removing the old Gitea database if you're changing your default database.


  1. Gitea community open letter, I also recommend checking out the Hacker News page, also timeline

  2. TODO