Heroku/Git:协议错误:错误的行长字符:错误

pho*_*rtx 5 git heroku

当我通过 git 部署到 heroku 时,slug 构建成功完成,但之后我收到一个 git 协议错误:

$ git push heroku -f v0.0.20:refs/heads/master

(...)    

remote: -----> Compressing...
remote:        Done: 55.3M
remote: -----> Launching...
remote:        Released v40
remote:        https://....herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
fatal: protocol error: bad line length character: erro
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'https://git.heroku.com/....git'
Run Code Online (Sandbox Code Playgroud)

我已经尝试通过 SSH 手动进入 git 服务器进行调试,但没有成功,由于 SSL,tcpdump 毫无用处。

ssh git@heroku.com "git-upload-pack ....git" 不产生任何可疑:

00c93a701c509d5730ba92e91463707699721929d477 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master agent=git/1.9.1
003f3a701c509d5730ba92e91463707699721929d477 refs/heads/master
0000
Run Code Online (Sandbox Code Playgroud)

我联系了 heroku 支持,他们试图将相同的代码推送到同一个应用程序,但有效。

我会很感激您提供有关如何调试该问题的任何建议。

pho*_*rtx 3

很难调试它,但同时我发现发生了什么事:

我已使用以下命令推送代码:

git push heroku -f v0.0.20:refs/heads/master
Run Code Online (Sandbox Code Playgroud)

通过将远程从 HTTPS URL 更改为 SSH URL,我收到了一条有用的错误消息:error: Trying to write non-commit object a3ab0fb2fda8d778850b3cbfc88e7e865d95daac to branch refs/heads/master

这让我意识到,我无法将 git tag 对象推送到远程分支引用。

对于这个问题有一个简单的解决方案:

git push heroku -f v0.0.20^{}:refs/heads/master
Run Code Online (Sandbox Code Playgroud)

gitrevisions手册页:

<rev>^{},例如v0.0.20^{} 后缀^后跟一个空大括号对 ( {}) 意味着该对象可能是一个标签,并递归地取消引用该标签,直到找到非标签对象。

换句话说:找到标签引用的最后一次提交。