Migrating git data (Gerrit) in the form of .git files to Gitea

Hi Community,

My organization was using git and gerrit based Version control, and we’re in the process of getting onto Gitea. We’ve already removed the gerrit application with all our repositories stored on an EFS, with all of the repositories in the .git format. I’ve also installed Gitea with authentication all set up. I need to now get all the existing repositories into the Gitea application. The new migration option in Gitea asks for a clone URL which unfortunately doesn’t exist anymore (as the gerrit application has been taken down due to vulnerabilities). Is there a way, by which, I could import these physical .git files to Gitea?

Any help or pointers with where to look at would be really appreciated.

Thanks,

PV66

I recently had to “migrate” a load of BARE repositories off a network share onto a gitea instance and the method I found that worked best was

  1. create gitea organisation
  2. create gitea target repository (NON initialised! )
  3. git clone --mirror /path/to/repository.git
  4. cd repository.git
  5. git gc
  6. git fsck
  7. mkdir .git
  8. mv * .git
  9. git config --local --book core.bare false
  10. git config --local --bool remove.origin.mirror false
  11. git reset --hard HEAD
  12. git remove set-url origin http:\url-of-gitea:3000
  13. git push --all origin
  14. git push --tags origin

This ensures all branches and tags are migrated. I had this in a bash script so I just had to set a couple of variables and then call it as git_migrate repo and with suitable variables set for /path/to/and also http:/url-of-gitea:300/ORG it would do it for me.

I did mean to extend it via curl to automate making the gitea target repository via swagger but with only ~20 to migrate it was easier just to make the target repo via the webUI

The easiest way is using Gitea’s adopt feature.
1 put all repositories according Gitea’s directory structure <user_name>/<repo_name>.git in the Gitea root directory
2 Login with admin account into Gitea and goto admin panel/repositories and search unadopted repositories and then adopt all the repositories.

Hi lunny,

I tried this, and gitea wasn’t able to locate any repositories.
Here’s the repository section of the app.ini file

[repository]
ROOT = /gitea/repos

I put my Test repo (Test.git) directory in this directory. Changed the ownership to git user.
The directory structure is now /gitea/repos/Test.git where everything is owned by git:grp-git

APP_NAME = Gitea
RUN_USER = git
RUN_MODE = prod

Just complains “No more unadopted repositories found”

All repositories should be organized according Gitea’s repository structure. i.e. <repo_owner>/<repo_name>.git in the root. And all names should be with lower name.

Thanks lunny, managed to get my test repo within gitea. I’ve authentication setup for users with Active Directory. I’ve also setup the repository visibility as public. Tried clone, add, commit and push from one of the users (other than gitea-admin), which works fine. Although the other users cannot see the repository on the UI. Is there any setting I’m missing besides making the repository public?

Are there any lock icon near your repository’s avatar?

Not that I can see. Hope this is what you were referring to.

This is a public repository.

Right yeah, I made it public, that is what is troubling me. Is making the repository public the only thing that needs to be done to allow everyone access to the repository? Cause, none of the authenticated users can see it on the UI. They are able to see it only if I add them as collaborator, which might be a painful task to perform on every other repository.

Managed to get this sorted!! Created a new organization, moved the repositories within the organization directory. Made all the repositories private, created teams (admin, devs) within the organization, and then granted appropriate permissions to teams and allocated repositories contingent on use to these teams. Doing so adds the group (members) as collaborators which is precisely how I wanted it to be!!

1 Like