I have some bare git repository on my filesystem where users do pull/push. I install gitea and can't find how to add it to gitea. Other git-management systems have something like "add repository from filesystem", "scan directory", etc. which added existing repo to system. How to add it in gitea?
2 Answers
At the moment I migrate from Filesystem Repositorys to Gitea.
How this could be done is heavily discussed here (we used SSH), where I got the basis for my approach.
The following steps worked for me:
Clone the repo.git folder to another location
git clone path/to/repo.git
Create an empty repo in Gitea. Either by hand or using the api
curl \ -X POST "http://localhost:3000/api/v1/user/repos" \ -H "accept: application/json" \ -H "Authorization: token MY_TOKEN*" \ -H "Content-Type: application/json" \ -d "{\"name\": \"REPO_NAME\"}" \ -i
Optionally transfer to a organization
curl \ -X POST "http://localhost:3000/api/v1/repos/CURRENT_OWNER/REPO_NAME/transfer" \ -H "accept: application/json" \ -H "Authorization: token MY_TOKEN*" \ -H "Content-Type: application/json" \ -d "{\"new_owner\": \"NEW_ORGANIZATION_OR_INDIVIDUAL\"}" \ -i
Push the repo to gitea
git remote add neworigin "http://localhost:3000/username/test.git"
git push neworigin --all
git push neworigin --tags

- 449
- 3
- 18

- 455
- 6
- 13
-
1Thanks for this answer, I think it will be more complete if a step to transfer to an organization is added. – bilogic Jan 31 '23 at 09:15
-
Thanks Lukas. You're a savior. I wrote a C# app, which reads the repository table from the old Gitea MsSql DB, and then using the gitea API creates the repositories in the new Gitea (with a MySql DB), transfers ownership to an organization, and then executes git commands to clone old repositories, add the new-origin and push to the new Gitea. Perfect. – Teo Bebekis May 02 '23 at 21:29
You can use the 'unadopted repositories' method (merged in this pull request as of sep 2020).
- Locate gitea's
app.ini
config file and find the values ofAPP_NAME
(the user name) and the repositoriesROOT
.
Let's assume your config looks like this:
APP_NAME = dinsdale
...
[repository]
ROOT = /usr/local/data/gitea-repositories
cd
to$REPO/$APP_NAME
which for the config above will be:/usr/local/data/gitea-repositories/dinsdale
and make a bare clone from each repo on your local file system:
cd /usr/local/data/gitea-repositories/dinsdale
git clone --bare /path/to/my/local/repo1
git clone --bare /path/to/my/local/repo2
..
git clone --bare /path/to/my/local/repo42
Click your profile icon in the top right corner and select Site Administration -> tab Repositories -> click Unadopted Repositories.
Leave the search field blank, and click the Search button. The 'unadopted' orphan folders that you added will be displayed below.
For each repo click the Adopt Files button to import the orphaned repo.
To manually convert a regular repo to a bare one see How to convert a normal Git repository to a bare one?

- 28,968
- 18
- 162
- 169