The easiest way to migrate repositories is to simply change where your local repository remote points to. In a locally cloned repository, assert that you should have a git remote (usually named
origin) by running
git remote -v:
origin email@example.com:username/repository.git (fetch) origin firstname.lastname@example.org:username/repository.git (push)
On your Codeberg dashboard, create a new repository (guide) and copy its upstream URL. You can then simply update the remote by running,
git remote set-url origin email@example.com:username/repository.git git push -u origin master # Or whatever other branch
maintaining a mirror
If you're not interested in fully migrating your repository over to Codeberg and would rather maintain a mirror, you can simply set up an additional remote as so,
# You can name the remote something other than codeberg git remote add codeberg firstname.lastname@example.org:username/repository.git git push codeberg master # Or whatever other branch
This of course means that in addition to just running
git push to push to a branch's regular upstream, you'd have to run
git push codeberg as well.
using the Gitea migration feature
Codeberg also offers a migration interface that can import Issues, Pull Requests, Releases, and more (an example imported issue).
To do this, you'll want to create a new personal access token by visiting this link. Under the “select scopes” header, you'll want to make sure you check the “repo” scope, giving it access to your repositories. You can read more on how to do this under the official GitHub documentation.
Next, you'll want to visit the Codeberg “New Migration” page. This can also be done by clicking the “New Migration” option under the same menu on the top right where you'd regularly create a new repository.
On the “New Migration” page, you should be greeted with a form split into 2 sections. Under the first section,
You'll want to populate the “Migrate/Clone From URL” input with your GitHub HTTPS clone URL. This is important such that other items would be made available under the “Migration Items” section.
Under “Clone Authorization”, you'll want to have your username filled as usual but have the GitHub access token set as the password. ⚠️ Do not use your actual password here!
The rest, such as the “Repository Name”, “Visibility”, “Migration Items”, and “Description” can be filled to your discretion.
Clicking the “Migrate Repository” should redirect you to a loading screen, and finally the brand new repository. Et voilà!