How to solve 'invalid repo name' Git error?

此生再无相见时 提交于 2019-12-01 06:14:57

问题


I've installed Gitolite, just like said in GitLab instructions, til now it was all ok, repo's created... but when tried to clone or push, it returns NO repo found - or something similar.

But when I set my remote to the full path like git@server:22/~git/repositories/repo.git it clones, but when try to push, its caught an error:

git push origin master
ERROR: invalid repo name.
fatal: The remote end hung up unexpectedly

What can it be?


回答1:


That error message comes from "gitolite-shell.parse_soc()"

sub parse_soc {
    my $soc = $ENV{SSH_ORIGINAL_COMMAND};
    $soc ||= 'info';

    my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
    if ( $soc =~ m(^($git_commands) '/?(.*?)(?:\.git(\d)?)?'$) ) {
        my ( $verb, $repo, $trace_level ) = ( $1, $2, $3 );
        $ENV{D} = $trace_level if $trace_level;
        _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
        trace( 2, "git command", $soc );
        return ( $verb, $repo );
    }

With REPONAME_PATT being:

$REPONAME_PATT = qr(^\@?[0-9a-zA-Z][-0-9a-zA-Z._\@/+]*$);

A gitolite address shouldn't include any path, like so:

git@server:22/repo

Instead of git@server:22/~git/repositories/repo.git, this issue is described here:

Consider git@server:repositories/reponame.git.
The clone operation will work -- you're using the full Unix path, (assuming default $REPO_BASE setting), and so the shell finds the repo where you said it would be.
However, when you push, gitolite's update hook kicks in, and fails to run because some of the environment variables it is expecting are not present.



来源:https://stackoverflow.com/questions/15396853/how-to-solve-invalid-repo-name-git-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!