fatal: The remote end hung up unexpectedly - The-Bioinformatics-Group/Albiorix GitHub Wiki

The following error message occurred when I was pushing a local repository to Gitlab.com:

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ git push
Counting objects: 65, done.
Delta compression using up to 64 threads.
Connection to gitlab.com closed by remote host.
fatal: The remote end hung up unexpectedly
Compressing objects: 100% (57/57), done.
error: pack-objects died of signal 13
error: failed to push some refs to '[email protected]:The-Bioinformatics-Group/Pomatoschistus_minutus_genome_project.git'
matsto@dna:/data01/Pomatoschistus_minutus_genome_project$

I suspect that some large files that had accidentally been committed to the repository made the ssh server time out. These files where first removed from the repository (but not the working area).

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ git rm --cached <LARGE FILE>

Large files in the history of the git repository was identified using a method described at http://blog.jessitron.com/2013/08/finding-and-removing-large-files-in-git.html. The code looks like this:

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ 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

They where then removed...

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ git filter-branch -f --tree-filter 'rm -rf PATH/TO/LARGE/FILE' HEAD

However, this did not really solve the problem and I'm not sure why. Stackoverflow to the rescue (http://stackoverflow.com/questions/6884331/git-repo-still-huge-after-large-files-removed-from-repository-history)!

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ git gc --aggressive --prune

And finally...

matsto@dna:/data01/Pomatoschistus_minutus_genome_project$ git push --force 
To https://gitlab.com/The-Bioinformatics-Group/Pomatoschistus_minutus_genome_project.git
 + 6166471...d58ccff master -> master (forced update)
matsto@dna:/data01/Pomatoschistus_minutus_genome_project$

Note: In the middle of this trial and error process I also change the remote from "[email protected]..." (ssh protocol) to "https://gitlab.com..." (https), hence the inconsistent output from git.

⚠️ **GitHub.com Fallback** ⚠️