Git Fatal Error: info/refs not found

后端 未结 7 1808
春和景丽
春和景丽 2020-12-17 15:54

I receive the following error:

fatal: https://github.com/username/repository-name.git/info/refs not found: did you run git update-server-info on the server?         


        
相关标签:
7条回答
  • 2020-12-17 16:26

    I had the same error info/refs not found when I was cloning a local repository and serving it via http.

    It seems that cloning a repository doesn't create the info/refs file and therefore it cannot been served remotely (https, ssh etc.) as remotely there is no way to get the name of the master branch without listing the .git folder, so the info/refs provides the path and the commitid for current git repository HEAD .

    mkdir clone-without-refs; cd clone-without-refs
    git clone ../origin.git .
    ls -l .git/info
    

    so I created it by hand this way (in the source repository, assuming you run a /bin/sh type of shell)

    gitid=$(git rev-parse  HEAD)
    echo HEAD: $gitid
    echo -e "$gitid\trefs/heads/master" > .git/info/refs
    if [ ! -e .git/refs/heads/master ]; then
        echo $gitid > .git/refs/heads/master
    fi
    

    then I did my cloning again and it worked (change $origin with yours):

    rm -rf ../cloned
    # checking if refs file is there (httpds server side):
    origin="http://localhost:8080/~$USER/$(pwd|sed -e "s,$HOME/,,")/.git"
    curl $origin/info/refs
    git clone $origin ../cloned
    # verify
    git -C ../cloned log -2
    
    0 讨论(0)
提交回复
热议问题