Migrating to Codeberg
GitHub and Open source are at times seem synonymous, on search engines looking for “git” usually returns https://git-scm.com and https://github.com, quite a bit further down there’s a mention of https://gitlab.com. Most people download the git CLI, maybe checkout the documentation and make an account on GitHub before going off down the path of exploring the rich landscape of projects, they clone, commit and push new contributions to existing projects and maybe even make their own project. Projects that help avid self-hosters like myself deploy, the ever-evolving web developer hosts NPM packages or the tinkerer who falls down the rabbit-hole of Neovim plugins or sway customisations, GitHub has something to offer for everyone. GitHub’s features promised to keep you hooked and the network effect only compounded overtime.
Uncertain future
With GitHub becoming an invaluable and integral to how FOSS works these days the features they offered were just a cherry on top of the git foundation, we were all really here for one thing and that was a git remote repository to help us collaborate. GitHub has one and only ONE main role, it needs to GIT and it damn well do it the same it the exact same way as the cli thats running on our machines.
The uptime and merge requests bugs left many of us feel rather concerned. The notion that git could be so fundamentally broken on GitHub is a rather shocking situation. Source control provides engineers with a single source of truth which we can trace, verify and replicate.
Personally these are the signs of complacency, slopiness, comfortable thinking we wouldn’t consider moving away, Microslop execs must be falling out of their chair laughing with the mere suggestion of people thinking about moving away from GitHub. They have a near monopoly stranglehold on the open source landscape with GitHub, they have a lot of power amassed through network effects.
Grass is greener?
GitLab does have a decent offering, they appear on the surface to be almost identical to GitHub and they even offer a GitLab CE (Community Edition) which you can self-host, what could go wrong? It seems their SaaS offering isn’t terrible, there’s very few outages and most importantly their Git works as you would expect back on their server, as far as we know.
Well there was this enormous red mark on their record from a few years ago. They lost 6H10M of git history when they wiped their database and were never able to recover all that lost work sadly. Although quite grave error on the surface, we can forgive them for this issue as no one person or organisation is perfect. The whole point of these SaaS offerings is to store a remote copy of our repos and collaborate with others, right?!
Putting aside this hopefully one-off horror show, the grass does look greener on GitLab. As usual there’s always more caveats, with their recent pivot to AI and offering their employees to take a seemingly more compasionate “voluntary separation” path. The push for AI might yet land us in the same predicament as GitHub where they push for their version of Copilot or some agentic product that sloppyfies their platform with changes that slowly but inevitably degrades the experience.
The Third Way
A colleague of mine told me a while back about Codeberg. Now this looks rather promising, a open and transparent non-profit foundation which develops its own git server called Forgejo which you can self host completely without a license.
They offer everything that GitHub and GitLab originally offered, a web UI where we can comment and review before merging and shipping code, in addition Codeberg Pages and a CI/CD offering too. What more could we ask for! This was the original promise of GitHub, no flaky uptime or fundemental bugs or even AI features.
Taking action
I decided to migrate onto Codeberg. This requires the creation of an empty repository on Codeberg which do not contain the README.md or LICENSE files for all the repositories you would like to migrate. Then you can go ahead and choose which path to take. I have tested and detailed below two paths I explored.
Simple-ish path
The simple route only copies over purely the git repository, the branches and commits. One option you can take is to mirror the repository to Codeberg with the following commands:
1
2
git clone --mirror ssh://git@github.com/username/repository.git
git push --mirror ssh://git@codeberg.org/username/repository.git
Once you’ve done this you can add the pushurl for the new repository to your .git/config on your local repository. This enables you to push to multiple repositories simultaneously.
1
2
3
4
5
6
[remote "origin"]
url = ssh://git@codeberg.org/username/repository.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = ssh://git@codeberg.org/username/repository.git
pushurl = ssh://git@github.com/username/repository.git
pushurl = ssh://git@gitlab.com/username/repository.git
You can also add the URLs with the following command and test that the push URL is configured correctly.
1
2
3
4
5
6
> git remote set-url --add --push origin git@codeberg.org:username/repository.git
> git remote -v
########################################################
origin git@codeberg.org:username/repository.git (fetch)
origin git@codeberg.org:username/repository.git (push)
origin git@github.com:username/repository.git (push)
You can keep repeating these steps until you migrate across all the relevant repositories to Codeberg. You can now push your changes codeberg as well as GitHub and GitLab. Job done end of story, for now.
Long-ish path
I wanted to create something a little more complete. I wanted to use Codeberg as my primary Git repository which mirrors to GitHub and GitLab. This allows me to keep a presence on those sites as Network effects can take some time to cleave people away from GitHub.
The previous steps were simple but didn’t migrate over the extras which Git WebUIs offer such as the Issue tracking, Merge Requests, Releases and more. For more established projects these are vital elements that need to be fully migrated without leaving your new home feeling a little incomplete.
To start with we needeed a Personal Access Token (PAT) generated on GitHub. GitLab for example offers a feature where you can this token to directly import all the repositories you own personally or organisations to which you belong. This makes it easy to transfer a bunch of repositories all in one go along with all the issues, branches, merge requests etc. with a peace of mind.
Codeberg also offers a migration feature, using the PAT we generated we can copy-paste GitHub URLs one at a time to migrate them over to Codeberg. Similar to GitLab this offers to migrate everything from Wiki to Issues to Releases.
We aren’t done yet however. With Codeberg, GitLab too, we can take advantage of the ability to mirror our repositories. Codeberg offers a SSH key based mirroring which generates a unique SSH key to Github and Gitlab to keep the mirrors repositories with minimum effort upon pushing new commits or periodically as little as every 10 minutes.
Bring the community
Now we are almost done, we can’t just abandon all the users who instinctively go to GitHub to make their contributions we need to inform people about this great new place where we’re all continuing our hardwork. Codeberg provides the following repository with badges to let people know where to find the code. They also offer a website to modify the default offerings.
We add this to the https://codeberg.org/username/.profile repository which works similarly to the user README.md on GitHub3 or GitLab landing pages. Setup a mirror between the username/.profile -> username/username to synchronise them together thus linking back to Codeberg so people know where to find your code’s new home.
Closing thoughts
So was this work worthwhile? It depends on your values. There’s a sense that FOSS projects sprout up, gain huge community support, get VC funding, incorporate in the US, change their license (turncoat) and the community moves to a fork. Codeberg’s implementation, ForgeJo, is itself a fork of gitea which has a colourful history, ironically also incorporated in the US. In this world maintaining a code on one centralised platform feels like an open goal. We don’t need to live paranoiacly but having backups makes us feel safer and is just plain smart.
As Codeberg is completely community-run I’m sure they appreciate a contribution, become a member or donation to keep their operations running. I’m not the biggest flag waving kind of person but more and more each day I feel like waving a little 🇪🇺 flag in support of the work done around this wonderful continent.
Doing research for this migration I came across the Give up GitHub campaign where they highlight the rights of users and the community as a key reason to move away from the platform. They suggest Codeberg but also Sourcehut which also appears to adhere to similar value proposition such as allowing self-hosting, no AI sloppification and more.







