convert git server from ssh to smart-http; ubuntu, apache; "Not a git repository " error

185 views Asked by At

I'm trying to convert a git repo from ssh access to smart-http access. I've found all sorts of old, contradictory advice; the most recent being here.

My client .git/config had the following URL originally:

url = git@my-domain:/path-to-repos/my-project.git

I've changed that to:

url = https://my-domain/my-project.git

When I issue the command (works fine with the git@url above):

git remote -v show origin

the apache server shows the following:

==> error.log <==
Not a git repository: '/path-to-repos/my-project.git'
==> access.log <==
a.b.c.d - - [12/Mar/2022:05:47:19 +0000] "GET /my-project.git/info/refs?service=
git-upload-pack HTTP/1.1" 404 4851 "-" "git/2.30.0"

repos are set drwxrwx--- git www-data

apache has mod cgi, alias, env enabled

apache site config file has:

SetEnv GIT_PROJECT_ROOT /path-to-repos
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAliasMatch \
    "(?x)^/(.*/(HEAD | \
    info/refs | \
    objects/(info/[^/]+ | \
    [0-9a-f]{2}/[0-9a-f]{38} | \
    pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
    git-(upload|receive)-pack))$" \
    "/usr/lib/git-core/git-http-backend/$1"
Alias /git /path-to-repos
<Directory /usr/lib/git-core>
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride None
    Require all granted

Any help would be much appreciated.

1

There are 1 answers

1
VonC On

I mentioned before that Alias /git ... means the HTTPS URL will include /git.

But as in my old post, the issue is one of permission:

cd /path/to/repo.git
sudo chgrp -R groupname .
sudo chmod -R g+rwX .
sudo find . -type d -exec chmod g+s '{}' +