Git push results in fatal: protocol error: bad line length character: This

后端 未结 21 835
春和景丽
春和景丽 2020-11-28 10:56

I am trying to get GitLab working on my server (running CentOS 6.5). I followed the gitlab-receipe to the line, but I just can\'t get it working. I am able to access the web

相关标签:
21条回答
  • 2020-11-28 11:24

    change the shell of git

    usermod -s /usr/bin/git-shell git
    
    0 讨论(0)
  • 2020-11-28 11:25

    The solution for me was to unset the GIT_SSH env variable which was pointing to putty (plink.exe)

    0 讨论(0)
  • 2020-11-28 11:27

    Another thing to check is that your .bashrc does not print extra stuff. For example 'echo "hello"' in .bashrc creates the error:

    kruus@borg:~/malt$ ssh snake01
    Last login: Tue Oct 21 10:44:31 2014 from 138.15.166.103
    hello
    ...
    kruus@snake01:/net/snake01/usr/hydra/kruus/malt$ git pull
    fatal: protocol error: bad line length character: hell
    

    Note how saying hello caused one hell of a problem.

    Removing the 'echo "hello"' from my .bashrc allows git to work as expected again. You may need to ">& /dev/null" to remove output if your .bashrc does more complicated things.

    0 讨论(0)
  • 2020-11-28 11:30
    sudo gitlab-ctl reconfigure
    

    and then

    sudo gitlab-ctl restart
    

    should do the trick

    0 讨论(0)
  • 2020-11-28 11:35

    My solution on Windows was switching the connection to SSH in .git/config:

    [remote "origin"] url = git@github.com:

    As described here:

    https://help.github.com/en/articles/changing-a-remotes-url

    0 讨论(0)
  • 2020-11-28 11:36

    You can get the actual error message by doing:

    ssh git@yourgitlabserver.com "git-upload-pack yournamespace/yourreponame.git"
    

    According to this git documentation git protocol expects at the beginning of each line its size and then the content. Looks like GitLab doesn't do that and sends the error message directly.

    0 讨论(0)
提交回复
热议问题