草庐IT

发送文件后,Ubuntu 上的 Git 通过 HTTP(不是 HTTPS)推送挂起

coder 2023-06-25 原文

我见过很多类似问题的实例,但它们通常似乎与 HTTPS(如下所示,我使用的是直接 HTTP)或缓冲区大小(我尝试使用“git config”设置缓冲区大小)有关http.postBuffer 524288000"即使我推送的文件是空的)或在客户端使用 Windows(我在 Ubuntu 上)。

我已经使用 git-http-backend 设置了一个 git 服务器,在服务器上创建了一个空的 repo,并在本地成功克隆了它。我添加了一个空文件并试图推送它,它上传然后在总行后挂起。

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push
07:07:45.884509 git.c:344               trace: built-in: git 'push'
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

07:07:45.886216 run-command.c:334       trace: run_command: 'git-remote-http' 'origin' 'http://user:password@server.com/git/tmp.git'
* Couldn't find host server.com in the .netrc file; using defaults
*   Trying 74.220.207.144...
* Connected to server.com (74.220.207.144) port 80 (#0)
> GET /git/tmp.git/info/refs?service=git-receive-pack HTTP/1.1
Host: server.com
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: text/html
< Content-Length: 134
< Connection: keep-alive
< WWW-Authenticate: Basic realm="Git Repo"
< Accept-Ranges: bytes
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Ignoring the response-body
* Connection #0 to host server.com left intact
* Issue another request to this URL: 'http://user:password@server.com/git/tmp.git/info/refs?service=git-receive-pack'
* Couldn't find host server.com in the .netrc file; using defaults
* Found bundle for host server.com: 0xedc7c0 [can pipeline]
* Re-using existing connection! (#0) with host server.com
* Connected to server.com (74.220.207.144) port 80 (#0)
* Server auth using Basic with user 'user'
> GET /git/tmp.git/info/refs?service=git-receive-pack HTTP/1.1
Host: server.com
Authorization: Basic anASDCNakvca0941cas65w==
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 200 OK
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: application/x-git-receive-pack-advertisement
< Content-Length: 127
< Connection: keep-alive
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Connection #0 to host server.com left intact
07:07:46.424994 run-command.c:334       trace: run_command: 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.425961 exec_cmd.c:120          trace: exec: 'git' 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.435357 git.c:344               trace: built-in: git 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.436162 run-command.c:334       trace: run_command: 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
07:07:46.436700 exec_cmd.c:120          trace: exec: 'git' 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
07:07:46.439015 git.c:344               trace: built-in: git 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
Counting objects: 3, done.
Writing objects: 100% (3/3), 200 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
* Couldn't find host server.com in the .netrc file; using defaults
* Found bundle for host server.com: 0xedc7c0 [can pipeline]
* Re-using existing connection! (#0) with host server.com
* Connected to server.com (74.220.207.144) port 80 (#0)
* Server auth using Basic with user 'user'
> POST /git/tmp.git/git-receive-pack HTTP/1.1
Host: server.com
Authorization: Basic anASDCNakvca0941cas65w==
User-Agent: git/2.7.4
Accept-Encoding: gzip
Content-Type: application/x-git-receive-pack-request
Accept: application/x-git-receive-pack-result
Content-Length: 336

* upload completely sent off: 336 out of 336 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: application/x-git-receive-pack-result
< Content-Length: 21
< Connection: keep-alive
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Connection #0 to host server.com left intact

在服务器 apache 错误日志中,此时我看到了这一行:

[Sat Sep 10 08:07:46 2016] [error] [client 204.15.222.20] fatal: The remote end hung up unexpectedly

最佳答案

首先,至少设置 git config --global push.default simple: 这样可以避免推送时出现噪音。

其次,确保客户端和服务器都使用 Git 2.10。
这将允许更多跟踪选项,例如最近的 GIT_TRACE_CURL .

第三,为了测试,尝试在Apache端停用身份验证,看看推送是否完成(之前有一个问题,在“git refuses to send credentials over http?”)


请注意,在 Git 2.17(2018 年第 2 季度)中,通常用于调试连接问题的 http 跟踪代码学会了从其输出中编辑潜在的敏感信息,以便可以更安全地共享。

参见 commit 8ba18e6 , commit 8341178 (2018 年 1 月 19 日)作者:Jonathan Tan (jhowtan) .
(由 Junio C Hamano -- gitster -- merge 于 commit 5327463 ,2018 年 2 月 13 日)

http: support omitting data from traces

GIT_TRACE_CURL provides a way to debug what is being sent and received over HTTP, with automatic redaction of sensitive information.
But it also logs data transmissions, which significantly increases the log file size, sometimes unnecessarily.

Add an option "GIT_TRACE_CURL_NO_DATA" to allow the user to omit such data transmissions.

关于发送文件后,Ubuntu 上的 Git 通过 HTTP(不是 HTTPS)推送挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39426995/

有关发送文件后,Ubuntu 上的 Git 通过 HTTP(不是 HTTPS)推送挂起的更多相关文章

  1. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  2. ruby - 其他文件中的 Rake 任务 - 2

    我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时

  3. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  4. ruby-on-rails - Rails 3 中的多个路由文件 - 2

    Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题

  5. ruby - 将差异补丁应用于字符串/文件 - 2

    对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl

  6. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  7. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  8. ruby - 如何模拟 Net::HTTP::Post? - 2

    是的,我知道最好使用webmock,但我想知道如何在RSpec中模拟此方法:defmethod_to_testurl=URI.parseurireq=Net::HTTP::Post.newurl.pathres=Net::HTTP.start(url.host,url.port)do|http|http.requestreq,foo:1endresend这是RSpec:let(:uri){'http://example.com'}specify'HTTPcall'dohttp=mock:httpNet::HTTP.stub!(:start).and_yieldhttphttp.shou

  9. Ruby 写入和读取对象到文件 - 2

    好的,所以我的目标是轻松地将一些数据保存到磁盘以备后用。您如何简单地写入然后读取一个对象?所以如果我有一个简单的类classCattr_accessor:a,:bdefinitialize(a,b)@a,@b=a,bendend所以如果我从中非常快地制作一个objobj=C.new("foo","bar")#justgaveitsomerandomvalues然后我可以把它变成一个kindaidstring=obj.to_s#whichreturns""我终于可以将此字符串打印到文件或其他内容中。我的问题是,我该如何再次将这个id变回一个对象?我知道我可以自己挑选信息并制作一个接受该信

  10. ruby - 如何使用 Ruby aws/s3 Gem 生成安全 URL 以从 s3 下载文件 - 2

    我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A

随机推荐