Hi mlebon,
Thanks to your tip and the setup of git-daemon
on the source Git server, I successfully managed to perform the migration directly from the Gitea web interface.
1. Adding the section you mentioned to /etc/gitea/app.ini
(the path to the configuration file may vary depending on the implementation or type of Gitea installation) on the Gitea server:
[migrations]
ALLOWED_DOMAINS =
ALLOW_LOCALNETWORKS = true
SKIP_TLS_VERIFY = true
BLOCKED_DOMAINS =
The only difference is that I left the ALLOWED_DOMAINS
directive empty, as per the Gitea documentation. Now, some directives are duplicated in the [security]
section of my Gitea config, but this doesn’t concern me at the moment.
2. Install git-daemon
on the original Git server.
The git-daemon enables the git://
protocol on your source git server.
The process was generated with the help of ChatGPT:
If Git is already installed on your server but you don’t have git-daemon
, which allows repositories to be served over the git://
protocol, install git-daemon
:
sudo apt update
sudo apt install git-daemon-run
3. Enabling chosen git repositories to be served with git-daemon
Now we’ll configure git-daemon
to serve the repositories that you already have in the /var/git
directory.
3.1. Ensure that the repositories have the correct permissions:
Ensure that the /var/git
folder and all repositories inside it belong to the git
user and group, so that git-daemon
can access them.
sudo chown -R git:git /var/git
3.2. Allow access via the git:// protocol:
To make a repository accessible via git://
, each migrated repository inside its folder (e.g., /var/git/repository-name.git
) must contain the git-daemon-export-ok
file (e.g., /var/git/repository-name.git/git-daemon-export-ok
). This file indicates that the repository can be exported.
For each repository in /var/git
that you want to make accessible, create this file:
cd /var/git/repository-name.git
sudo touch git-daemon-export-ok
For example, if you have a repository named repository-name.git
, use:
cd /var/git/repository-name.git
sudo touch git-daemon-export-ok
I personally used this set of commands to set up all repositories:
bash
sudo -u git -s
cd /var/git
for i inls
; do [ -d “$i” ] && touch “$i/git-daemon-export-ok”; done
exit
4. Starting git-daemon
temprorarily:
I decided to run git-daemon
only temporarily because
a) it is an anonymous service and anyone can pull your repositories
b) this way seemed sufficient for the migration
c) running it permanently as a systemd service is considered unsafe as per a)
Start git-daemon
with the appropriate parameters—this is a one-time run of the daemon, so it will stop when you close the terminal or press CTRL+C:
sudo git daemon --reuseaddr --base-path=/var/git/ --export-all --verbose --enable=receive-pack --port=9418
This command does the following:
--reuseaddr
: Ensures that the socket can be reused when the daemon restarts.
--base-path=/var/git/
: Sets /var/git/
as the root directory where repositories are searched for.
--export-all
: Exports all repositories that have the git-daemon-export-ok
file.
--verbose
: Ensures that the daemon logs detailed information.
--enable=receive-pack
: Allows receiving git push
(this is optional if you only want read-only access) - perhaps this one is not necessary for migration purposes.
--port=9418
: This is the port where Gitea expects the git://
protocol to run.
5. Once git-daemon
is running…
Perform the migration from the Gitea web interface using the Migrate / Clone From URL:
parameter with git://server.ip.or.known.hostname/repository-name.git
.
Since git-daemon
doesn’t support/require authorization, I left the username and password fields empty.
In the Git URL for the migration, I only entered the repository name (the repo name only including .git
), as the rest of the path is set by the --base-path=/var/git/
above.
That’s it. Now, while git-daemon
is running, I’m gradually migrating all repositories to the Gitea server.
After the migration is complete, be sure to exit git-daemon
, otherwise the repositories will remain accessible to anyone.
P.S.: Even though I’m responding to the Gitea to Gitea migration topic and my post describes a Git to Gitea migration, I assume that with the right git-daemon setup, the procedure could work for a Gitea migration as well.