Git 被困在写对象上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34601295/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:40:27  来源:igfitidea点击:

Git gets stuck on writing objects

gitgithubgit-push

提问by Gary Robinson

I am trying to git push --alland it just hangs on writing objects

我正在尝试git push --all,它只是挂在写对象上

10.0-final-project git:(master) ? git push --all
Counting objects: 134, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (129/129), done.
Writing objects:  32% (44/134), 321.56 MiB | 231.00 KiB/s

The 321.56 MiB and 231.00 KiB/s continues to go up.

321.56 MiB 和 231.00 KiB/s 继续上升。

I have tried using git config --global http.postBufferand git config --global sendpack.sideband false

我试过使用git config --global http.postBuffergit config --global sendpack.sideband false

Nothing is working. What is the way to resolve this issue?

没有任何工作。解决此问题的方法是什么?

回答by LShi

I got the same problem. But the cause was the current user didn't have write permission to the destination dir.

我遇到了同样的问题。但原因是当前用户没有目标目录的写权限。

回答by CodeWizard

Looks like you have added a HUGEbinary files or folder to GIT.

看起来您已经向 GIT添加了一个巨大的二进制文件或文件夹。

Its not something you should do with git.

它不是你应该用 git 做的事情。

If this is the case consider solutions like: Git Large File Storage

如果是这种情况,请考虑以下解决方案:Git Large File Storage

Another relative articlecan be found here with some sample code for cleaning the repo.

可以在此处找到另一篇相关文章,其中包含一些用于清理存储库的示例代码。



Step 1: Identify the large files.

步骤 1:识别大文件。

We need to search through all of the history to find the files that are good candidates for deletion. As far as I can tell, this is nontrivial, so here is a complicated command that lists the sum of the sizes of all revisions of files that are over a million bytes. Run it on a mac.

我们需要搜索所有历史记录以找到适合删除的文件。据我所知,这很重要,所以这里有一个复杂的命令,它列出了超过一百万字节的所有文件修订的大小总和。在 Mac 上运行它。

git rev-list master | while read rev; do git ls-tree -lr $rev | cut -c54- |     grep -v '^ '; done | sort -u | perl -e '
  while (<>) {
      chomp;
      @stuff=split("\t");
      $sums{$stuff[1]} += $stuff[0];
  }
  print "$sums{$_} $_\n" for (keys %sums);
 ' | sort -rn >> large_files.txt

Step 2: Remove them like they were never there.

第 2 步:将它们移除,就像它们从未存在过一样。

This is the fun part. If large_files.txt is still in the same format as before, do this:

这是有趣的部分。如果 large_files.txt 的格式仍与以前相同,请执行以下操作:

git filter-branch --tree-filter 'rm -rf `cat /full/path/to/large_files.txt |
    cut -d " " -f 2` ' --prune-empty <BRANCHES>