Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git gets stuck on writing objects

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

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.

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

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

like image 991
Gary Robinson Avatar asked Jan 04 '16 22:01

Gary Robinson


People also ask

Why is my git push not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

Why does git push takes so long?

If you are starting a new project from a clone, (from the CLI without a fork) when you push to a blank remote you are pushing the entire history of the project you just cloned. This is going to take some time.

What is enumerating objects in git?

What does “Enumerating objects” mean? When you create a new repo, the first push collects all objects and sends them in a single pack-file to the remote. This is essentially the same operation as a git clone, but in reverse.

What is git push origin master?

Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.


2 Answers

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

Its not something you should do with git.

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

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


Step 1: Identify the large files.

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.

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.

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

git filter-branch --tree-filter 'rm -rf `cat /full/path/to/large_files.txt |
    cut -d " " -f 2` ' --prune-empty <BRANCHES>
like image 115
CodeWizard Avatar answered Sep 17 '22 11:09

CodeWizard


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

like image 33
LShi Avatar answered Sep 21 '22 11:09

LShi