I’m trying to translate our subversion repository to git using subgit tool. I established subversion to git repositories successfully and it has been working normally some time, but changes from subversion stopped to appear in git after I rebooted by workstation. I ran subgit install once again and it works for now, but I think it’s not correct way. How can I set subgit so that it continues to work after reboot?
3 Answers
Indeed, SubGit runs a daemon to check for new SVN changes (once a minute by default). The daemon starts automatically if not started on every Git push, so if Git pushes to your repository occur often enough and you don't care much about having new SVN changes immediately, you can just do nothing and with the first Git push the daemon will start.
But if it's important for you to have Git repository up-to-date, you need to run
$ subgit fetch --async /path/to/git/repository
when the system starts. The command will start the daemon synchronizing the repository with SVN. Note that it's important to run all SubGit commands including this one on behalf of the same user (it should also be the owner of /path/to/git/repository ; usually, it's "git" if you're using GitLab or "www-data" if you're using Apache and git-http-backend ).
One of the approaches would be to create an init.d
script starting SubGit daemon with
$ su -u git subgit fetch --async /path/to/git/repository
and stopping it with:
$ su -u git subgit shutdown /path/to/git/repository
If your system is debian, you can use this init.d
script generator.
I'm one of SubGit developers.

- 8,530
- 3
- 30
- 38
-
are you serious? I really need to add 50+ lines to my init files to start each and every repo independently? – Simon Schmeißer Apr 12 '19 at 13:06
Just an extension to what Dmitry-pavlenko stated, with systemd, i was able to follow this post and do the following to add subgit to systemd in my gitlab container:
echo '[Unit]
Description=Kick off subgit daemon on boot
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo OFF > subgit fetch --async /var/opt/gitlab/git-data/repositories/ProjectGroup/RepoName.git"
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/subgit.service
systemctl enable subgit.service
replace ProjectGroup and RepoName with values that any subgit setup repo you have running uses, and this will create a service file and add it to system startup.
I am very new to unix systems, so if you have any changes or recommendations for the above, feel free to suggest/add/change! Thanks for the great information above too.

- 652
- 6
- 18
I updated the script by @evan-morrison to:
cat > /etc/systemd/system/subgit.service << 'EOSERVICE'
[Unit]
Description=Kick off subgit daemon on boot
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'cd /tmp ; for s in "/var/opt/gitlab/git-data/repositories/@hashed/"*/*/*.git/subgit/ ; do echo OFF | sudo -u git subgit fetch --async "$(realpath "$s/..")" ; done'
[Install]
WantedBy=multi-user.target
EOSERVICE
systemctl enable subgit.service
I think the echo OFF >
was wrong and I changed that to echo OFF |
which is likely unneeded.
The above configuration finds the repositories on its own (on a gitlab server), assuming there is a subgit directory present in the relevant repositories.

- 445
- 3
- 12