Reputation: 2571
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?
Upvotes: 15
Views: 16980
Reputation: 31756
You can use the unadopted repositories method (merged in this pull request as of sep 2020).
app.ini
config file and find the values of APP_NAME
(the user name) and the repositories ROOT
. 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?
Upvotes: 5
Reputation: 41
There is also a built-in feature called push to create that allows you to create new repos on the fly from existing repos. You need to add both there options inside the repository block in app.ini as shown below then just restart the gitea daemon.
[repository]
ENABLE_PUSH_CREATE_USER = true
ENABLE_PUSH_CREATE_ORG = true
After this is done you can run the following commands to push and create the repo on demand.
git remote add origin git@{domain}:{username}/{repo name that does not exist yet}.git
git push -u origin main
See more at https://docs.gitea.com/usage/push#enabling-push-to-create
Upvotes: 4
Reputation: 721
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
*https://docs.gitea.io/en-us/api-usage/
Upvotes: 9