Git推送导致致命的:协议错误:错误的行长度字符:此

Git推送导致致命的:协议错误:错误的行长度字符:此,git,ssh,repository,gitlab,Git,Ssh,Repository,Gitlab,我正在尝试让GitLab在我的服务器上工作(运行CentOS 6.5)。我跟着电话线走,但就是没法让它工作。我可以访问web界面,创建新项目,但推送到主分支会返回以下错误: fatal: protocol error: bad line length character: This 我已经对生产环境进行了检查,结果如下: Checking Environment ... Git configured for git user? ... yes Checking Environment ..

我正在尝试让GitLab在我的服务器上工作(运行CentOS 6.5)。我跟着电话线走,但就是没法让它工作。我可以访问web界面,创建新项目,但推送到主分支会返回以下错误:

fatal: protocol error: bad line length character: This
我已经对生产环境进行了检查,结果如下:

Checking Environment ...

Git configured for git user? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version >= 1.7.9 ? ... OK (1.8.0)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ... 
ASC / Wiki ... repository is empty
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files: 
    /home/git/repositories: OK
    /home/git/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.4.10
Send ping to redis server: PONG
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking LDAP ...

LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... no
  Try fixing it:
  Redownload the init script
  For more information see:
  doc/install/installation.md in section "Install Init Script"
  Please fix the error above and rerun the checks.
projects have namespace: ... 
ASC / Wiki ... yes
Projects have satellites? ... 
ASC / Wiki ... can't create, repository is empty
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.8.3)

Checking GitLab ... Finished
对于初始化脚本错误,收据上说

如果您确信已下载,则不必介意该错误 最新的

因此,由于我已经下载了最新的一个,我真的不能做太多


在过去的一周里,我一直在绞尽脑汁,弄不明白为什么会发生这个错误,如果有任何帮助,我将不胜感激

如果其他任何人有此问题,解决方案是将用户“git”(或您的用户被称为什么)的登录shell更改为
/bin/bash
。这可以通过以下命令完成:
usermod-s/bin/bash-git
()。更改登录shell的原因是,git用户的默认shell是
/sbin/nologin
(或类似的,取决于环境),这会阻止git应用程序以git用户的身份登录git服务器。

另一个需要检查的事项是.bashrc不会打印额外的内容。 例如,.bashrc中的“echo“hello”会创建错误:

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
请注意,打招呼是如何引起一个大问题的


从my.bashrc中删除“echo”hello“允许git再次按预期工作。如果.bashrc执行更复杂的操作,您可能需要“>&/dev/null”来删除输出。

另一种可能是您拼错了存储库名称

过去两天我做了两次。我添加了一个remote并拼错了它,在GitLab上创建项目时,我拼错了名称

在这两种情况下,当我试图推到遥控器时,我得到了

fatal: protocol error: bad line length character: No s
所以检查一下拼写


另外,如果您使用其他名称(如组)创建项目,请确保您添加的是远程设备。

解决我的问题的方法是,我忘记为项目添加部署密钥(针对我尝试部署为的用户)

在中添加一个部署密钥可以解决问题

sudo gitlab-ctl reconfigure
然后

sudo gitlab-ctl restart
在我的情况下(通过~/.ssh/config的私钥),我必须在以下内容中省略ssh部分:

git clone ssh://git@hostname:username/repository.git
它与:

git clone git@hostname:username/repository.git
错误消息为:

致命:协议错误:错误的行长度字符:无s


您可以通过执行以下操作来获取实际的错误消息:

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

根据git协议,在每行的开头都会显示其大小,然后显示内容。看起来GitLab没有这样做,而是直接发送错误消息

我今天遇到了这个错误消息(“No s”),这实际上与我无权推送到目标存储库有关。尽管错误消息非常奇怪,但这可能有助于人们继续工作


我们使用Gitlab。

仅供其他用户参考:

fatal: protocol error: bad line length character: no s
can be a truncated answer for "No such project".
在我的例子中,可以通过将用户(甚至您自己)添加到gitlab中的项目来修复此类错误:

另外,确保在用户
配置文件设置>SSH密钥或项目>设置>部署密钥中设置了公钥


在我的情况下,我的用户名已更改,并且此存储库的git配置未更新以匹配新名称

检查git遥控器,确保它们指向正确的位置:

git-remote-v

通过手动编辑配置来更新配置:

vim.git/config

或者通过命令


git远程设置url源https://github.com/USERNAME/OTHERREPOSITORY.git

将我的经验添加到这个已经很长的可能解决方案列表中

在我的例子中,我可以访问我克隆的repo,但无法访问
package.json
所指的依赖项或devdependency的其他内部repo。
因此,解决方案就是获得这些回购协议的访问权。

我也遇到了同样的问题,结果证明我在一家git分支机构工作。我所需要做的就是把它推给主人

$ git push <remote> <local branch name>:<remote branch to push into>
$git推送:

我的错误是:
致命:协议错误:错误行长度字符:无s

这是因为我忘记在Maven项目的pom.xml中指定SCM标记,所以它使用了来自父项目的SCM信息。
我还必须将我们的Jenkins用户添加到GitLab的项目中。

更改git的shell

usermod -s /usr/bin/git-shell git

只是在我的情况下为其他人添加一个可能的解决方案。 在我的情况下,我试图推动一个标签

git push heroku MYTAG:master
直到我取消了对标签的引用,它才起作用

git push heroku MYTAG^{}:master
您可以在此处阅读更多信息:

^{},例如v0.99.8^{}

后缀“^”后跟空大括号对表示对象可以是标记,并递归地取消对标记的引用,直到找到非标记对象为止


当我想要推送我的提交时,我遇到了以下错误:

fatal: protocol error: bad line length character: No s
我通过ssh连接检查解决了这个问题:

ssh Git@hostIp

我的解决方案是取消设置指向putty(plink.exe)的GIT_SSH env变量

也有同样的问题,在我的例子中,原始repo被移动了,更改了.GIT/config解决了我的问题。

在我的例子中,通过使用
chsh
将远程GIT用户shell更改为
GIT shell
,错误得到了修复:

chsh -s $(command -v git-shell) git

官方
gitshell
。出于安全原因,强烈建议在远程存储库服务器上为git用户使用此shell。

在我的示例中,我只在Windows的“SSH扩展”中观察到此错误


从命令行执行相同的命令。我将SSH设置从PuTTY切换到OpenSSH,它停止生成错误。

我在Windows上的解决方案是在.git/config中将连接切换到SSH:

[远程“源”] url=git@github.com:

如下所述:

另一个

我的配置有点复杂。在服务器端,我使用self-ho
PTY allocation request failed on channel 0
This service allows sftp connections only.
Connection to my.server.name closed.
PTY allocation request failed on channel 0
Hi there, You've successfully authenticated, but Gogs does not provide shell access.
If this is unexpected, please log in with password and setup Gogs under another user.