I'm trying to initialize a git repo and then serve it using the git daemon. Everything with GitPython.
Initializing the repo works:
temp_dir = '/tmp/something'
repo = git.Repo.init(temp_dir)
Starting the daemon as well:
gd = Git().daemon(temp_dir, enable='receive-pack', listen='127.0.0.1', port=GIT_DAEMON_PORT,as_process=True, export_all=True)
gd.proc.wait()
But I'm not able to access the repo:
git clone git://127.0.0.1:9418/something
Cloning into 'something'...
fatal: remote error: access denied or repository not exported: /something
I'm not sure if I have to initialize the repo as bare, or if I have to specify the base_path when starting the git daemon... tried it all. Does anybody have some pointers?
PS: I've seen a similar approach here: https://github.com/gitpython-developers/GitPython/blob/master/git/test/lib/helper.py
Figured it out, Thanks to user3159253.
import git
import tempfile
tmpdir = tempfile.TemporaryDirectory(suffix='.git')
repo = git.Repo.init(tmpdir.name, shared=True, bare=True)
repo.daemon_export = True
gd = git.Git().daemon(tmpdir.name,
enable='receive-pack',
listen='127.0.0.1',
port=9418,
as_process=True,
verbose=True
)
gd.proc.wait()
Now you can clone that repo using:
$git clone git://127.0.0.1:9418/tmp/<name-of-tmpdir>.git