Git pull 很慢.. 为什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22040246/
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 pull is very slow.. why?
提问by ioleo
Note I have studied the git-is-very-very-slowquestion, but in their case the reason was big binary files - while in my repository there is PHP/JS/HTML/CSS only code (no binaries) and the biggest file in the repository is around 800 KB.
注意我已经研究了git-is-very-very-slow问题,但在他们的情况下,原因是大的二进制文件 - 而在我的存储库中只有 PHP/JS/HTML/CSS 代码(没有二进制文件)和最大的文件存储库中的大小约为 800 KB。
I've changed one file (a few lines), then git add .
and git commit -m "msg"
, then git push origin master
.
我已经更改了一个文件(几行),然后git add .
和git commit -m "msg"
,然后git push origin master
.
On some other machine, when I do git pull origin master
it downloads a few MiB of data, and it takes more than 2 minutes to calculate the delta and apply changes. Something is terribly wrong here.
在其他一些机器上,当我git pull origin master
下载一些 MiB 数据时,计算增量和应用更改需要 2 多分钟。这里有些不对劲。
I suspect some recent operations may cause this:
我怀疑最近的一些操作可能会导致这种情况:
recently, I've accidentally added many vendor assets (bower_components
assets)
when I realized it, I've used git rm
to remove them from repository (and ofcourse, git add
, git commit
and git push
to upstream)
最近,bower_components
当我意识到时,我不小心添加了许多供应商资产(资产),我习惯于git rm
将它们从存储库中删除(当然,还有git add
,git commit
和git push
上游)
That was a few days ago and the problems I have right now started happeing around that time.
那是几天前,我现在的问题在那个时候开始出现。
I have two questions:
我有两个问题:
- why this is happeing?
- how can I fix my repository?
- 为什么会这样?
- 如何修复我的存储库?
Note: I am the only one useing and pushing to this repo.
注意:我是唯一一个使用和推送到这个 repo 的人。
采纳答案by ioleo
The problem was in EmberJS
app directory. It contained node_modules
and bower_components
directories which kept third-party libraries used by GruntJS
to build my JS and CSS assets.
问题出在EmberJS
应用程序目录中。它包含了node_modules
与bower_components
目录里面存放使用第三方库GruntJS
来构建我的JS和CSS的资产。
Each of these contained many files and directories.. considering that the dependency tree contained hundreds of libraries of size varying from small (few files) to big fat (many files).
其中每一个都包含许多文件和目录......考虑到依赖关系树包含数百个大小不等的库,从小(几个文件)到大胖(许多文件)。
After removing these directories and ignoring them, the git repository works fast again.
删除这些目录并忽略它们后,git 存储库再次快速运行。
回答by Sander Stad
I have had the same issue when I was dealing with thousands of small files. The thing that fixed it for me was to set the postbuffer in git repo's config
在处理数千个小文件时,我遇到了同样的问题。为我修复它的事情是在 git repo 的配置中设置 postbuffer
git config http.postBuffer 524288000
Instead of uploading with 18KB/s it suddenly went the full bandwidth
不是以 18KB/s 的速度上传,而是突然占用了全部带宽
回答by NessBird
I had a similar experience -- git pull and push suddenly starting to run EXTREMELY slowly, taking ten minutes or more, both on my local Mac OSX and on my Linux / Apache server. I deleted the local copy of the repo on my Mac, and recloned it, and it started to run fine. Did the same thing on the server, and all is well. I suppose it was somehow corrupted?
我有类似的经历——git pull 和 push 突然开始运行非常缓慢,需要十分钟或更长时间,无论是在我的本地 Mac OSX 上还是在我的 Linux / Apache 服务器上。我在 Mac 上删除了该存储库的本地副本,然后重新克隆它,它开始运行良好。在服务器上做了同样的事情,一切都很好。我想它以某种方式损坏了?
回答by JGL
I had the same issue. For me this was a IPv4/IPv6 issue. I fixed it forcing SSH to use IPv4.
我遇到过同样的问题。对我来说,这是一个 IPv4/IPv6 问题。我修复了它强制 SSH 使用 IPv4。
Set "AddressFamily inet" in /etc/ssh/ssh_config to force IPv4 connection. Then restart ssh client sudo service ssh restart
在 /etc/ssh/ssh_config 中设置“AddressFamily inet”以强制 IPv4 连接。然后重启ssh客户端sudo service ssh restart
More info here.
更多信息在这里。
回答by Eli Berkowitz
I tried all solutions in this thread with no luck. I tried using git protocol 2 at the suggestion of a coworker, which ended up being very effective (went from waiting 3 minutes for pulls/pushes to start to a few seconds)
我尝试了这个线程中的所有解决方案,但没有成功。我在同事的建议下尝试使用 git 协议 2,结果非常有效(从等待 3 分钟拉/推开始到几秒钟)
git config --global protocol.version 2
回答by ATHER
Just incase if someone is stumble upon this thread, before deleting your .git folder, try to restart your wifi, that may be just your wifi connection issue.
以防万一有人偶然发现此线程,在删除您的 .git 文件夹之前,请尝试重新启动您的 wifi,这可能只是您的 wifi 连接问题。