Git fetch/pull/clone挂在接收对象上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11941175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git fetch/pull/clone hangs on receiving objects
提问by gabeb
When fetching or pulling from git repositories, or cloning a repository, I get to this point:
从 git 存储库中获取或拉取,或克隆存储库时,我到了这一点:
remote: Counting objects: 6666, done.
remote: Compressing objects: 100% (5941/5941), done.
Receiving objects: 23% (1534/6460), 11.68 MiB | 23 KiB/s
And it hangs. The 23%/number of objects isn't a given, it ranges from single digits to up to the 60s, it seems. Also the speed for download listed freezes -- it's not like it slowly crawls down towards zero.
它挂了。对象的 23%/数量不是给定的,它的范围从个位数到 60s,似乎。此外,列出的下载速度会冻结——它不像是慢慢地向零爬行。
The guy I sit next to has no issues, so it's not a router problem. We use beanstalk for our work repositories, but I have the issue from beanstalk and github (although occaisonally it seems a github one will finish).
我坐在旁边的那个人没有问题,所以这不是路由器的问题。我们将 beanstalk 用于我们的工作存储库,但是我遇到了 beanstalk 和 github 的问题(尽管有时似乎 github 会完成)。
The problem has only seemed to crop up since upgrading to Mountain Lion and updating Xcode. I've wiped git (including XCode's) and tried installing it with homebrew. That didn't work, so I removed it and tried with their provided Mac installation package which also didn't fix the issue.
自从升级到 Mountain Lion 并更新 Xcode 后,问题似乎才出现。我已经擦除了 git(包括 XCode 的)并尝试使用自制软件安装它。那没有用,所以我删除了它并尝试使用他们提供的 Mac 安装包,但也没有解决问题。
Beanstalk provides SSH urls for the git repository, but I've had no issues with connecting via SCP or SSH to servers that I've done work on.
Beanstalk 为 git 存储库提供了 SSH url,但我在通过 SCP 或 SSH 连接到我已经完成工作的服务器时没有遇到任何问题。
This is killing my workflow so any help would be much appreciated!
这正在扼杀我的工作流程,所以任何帮助将不胜感激!
回答by Anand Rockzz
VMware on NAThad this problem for me. Changing it to Bridged (replicate the state)fixed the issue.
NAT 上的VMware 对我来说有这个问题。将其更改为桥接(复制状态)解决了该问题。
回答by cjayho
Try to check your network connection. Maybe there is a garbage in the routing table. Maybe broken port on your router or your computer's network interface problem. Try to ping server from which you are cloning git repo, maybe link between your computer and this server is unstable.
尝试检查您的网络连接。也许路由表中有垃圾。可能是路由器上的端口损坏或计算机的网络接口问题。尝试 ping 从中克隆 git repo 的服务器,可能您的计算机和该服务器之间的链接不稳定。
回答by driek
Looks similar to mine problem. Git seemed to hang on fetch or push after a certain short amount of time.
I can advice you to put in ~/.ssh/config
:
看起来和我的问题很相似。Git 似乎在 fetch 或 push 上停留了很短的一段时间。我可以建议你输入~/.ssh/config
:
Host *
ServerAliveInterval 60
I have a MBP with also mountain lion. I hope this timeout is the cause for your problem. (After thirty or forty minutes or so, I noticed that it continued.)
我有一个 MBP 和山狮。我希望这个超时是导致您问题的原因。(三十或四十分钟左右后,我注意到它仍在继续。)
回答by VonC
On Mac, git fetch should be more resistant to this kind of issue, with Git 2.22 (Q2 2019): On platforms where "git fetch" is killed with SIGPIPE (e.g. OSX), the upload-pack
that runs on the other end that hangs up after detecting an error could cause "git fetch
" to die with a signal, which led to a flakey test.
"git fetch
" now ignores SIGPIPE during the network portion of its operation (this is not a problem as we check the return status from our write(2)s).
在 Mac 上,git fetch 应该更能抵抗此类问题,使用 Git 2.22(2019 年第二季度):在使用 SIGPIPE 杀死“git fetch”的平台(例如 OSX)upload-pack
上,在另一端运行的检测到错误可能会导致 " git fetch
" 因信号而死亡,从而导致 flakey 测试。
" git fetch
" 现在在其操作的网络部分忽略 SIGPIPE(这不是问题,因为我们检查了我们的 write(2)s 的返回状态)。
See commit 1435889(03 Mar 2019), and commit 37c8001(05 Mar 2019) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
--in commit 27cdbdd, 20 Mar 2019)
见犯1435889(2019年3月3日),并提交37c8001(2019年3月5日),由杰夫·王(peff
)。
(由Junio C gitster
Hamano合并-- --在commit 27cdbdd,2019 年 3 月 20 日)
fetch
: ignoreSIGPIPE
during network operationThe default
SIGPIPE
behavior can be useful for a command that generates a lot of output: if the receiver of our output goes away, we'll be notified asynchronously to stop generating it (typically by killing the program).But for a command like
fetch
, which is primarily concerned with receiving data and writing it to disk, an unexpectedSIGPIPE
can be awkward. We're already checking the return value of all of ourwrite()
calls, and dying due to the signal takes away our chance to gracefully handle the error.On Linux, we wouldn't generally see
SIGPIPE
at all during fetch. If the other side of the network connection hangs up, we'll seeECONNRESET
.
But on OS X, we get aSIGPIPE
, and the process is killed.Let's ignore
SIGPIPE
during the network portion of the fetch, which will cause ourwrite()
to returnEPIPE
, giving us consistent behavior across platforms.
fetch
:SIGPIPE
网络运行时忽略默认
SIGPIPE
行为对于生成大量输出的命令很有用:如果输出的接收器消失,我们将异步通知停止生成它(通常通过终止程序)。但是对于像 一样
fetch
主要关注接收数据并将其写入磁盘的命令,意外SIGPIPE
可能会很尴尬。我们已经在检查所有write()
调用的返回值,由于信号而死亡会剥夺我们优雅地处理错误的机会。在 Linux 上,我们通常
SIGPIPE
在获取期间根本看不到。如果网络连接的另一端挂断,我们会看到ECONNRESET
。
但是在 OS X 上,我们得到一个SIGPIPE
,并且进程被终止。让我们
SIGPIPE
在 fetch 的网络部分忽略它,这将导致我们write()
的 returnEPIPE
,为我们提供跨平台的一致行为。
回答by Damian Wojcik
first try to initialize git repository folder by typing
首先尝试通过键入来初始化 git 存储库文件夹
$ git init
it should help
它应该有帮助