Search code examples
gitgithubsugarcrm

Git error: remote unpack failed when pushing to a bare repo


I'm having trouble with switching my local SugarCRM instance from a gitlab repo to a new github repo. Locally, the project is on a vagrant VM running on a Windows 10 host. I run git commands from the host machine. I created a new private github repo, set it as the new remote, and generated a new public/private ssh key pair on the host machine in C:\Users\.ssh. When I try to push the project to the remote repo for the first time, I get

Enumerating objects: 58649, done.
error: remote unpack failed: eof before pack header was fully read
error: failed to push some refs to '[email protected]:yvoloshin-fidelus/Sugar.git'

This image shows a more detailed error message that I got from Github Desktop.

While following this SO post, I tried

git gc --aggressive --prune=now

and got this:

fatal: bad object refs/remotes/origin/HEAD
error: failed to run repack 

Other git commands I tried with their outputs:

git count-objects -vH

warning: garbage found: .git/objects/pack/tmp_pack_2dy4gc
warning: garbage found: .git/objects/pack/tmp_pack_tnF02a
warning: garbage found: .git/objects/pack/tmp_pack_XY7JBa
count: 4904
size: 10.77 MiB
in-pack: 68200
packs: 4
size-pack: 1.15 GiB
prune-packable: 0
garbage: 3
size-garbage: 1.32 GiB

git gc --aggressive --no-prune

Enumerating objects: 65624, done.
error: failed to run repack25/65624)

These commands had no effect on the original error. What else should I try here?


Solution

  • EDIT/UPDATE: What actually did the trick for OP was git update-git-for-windows. See comments for details!

    Things I'd try in such situations:

    • Make sure my current user owns all the current git-internal files, as lacking permissions can interfere with various git operations.
      • Linux: sudo chown -R --changes "$USER" .git
      • Windows: open main folder permissions and let the permissions get rolled down via the Advanced Security Settings dialog (using ☑ Replace all child object permissions with inheritable permissions from this object)
    • On Windows: Make sure the path isn't long, as the Windows filesystem NTFS will mess up git if paths get longer than 255 chars/bytes. Keep in mind that the regular git object paths alone (e.g. .git/objects/fe/73f087d8c25fbc1159a50434ef9bf15773e7ac) have a length of 55 characters. Also that special unicode characters can consume more than 1 byte of the file path. Also files in the repo that exceed the maximum path lengths can become problematic for some operations. In worst case just move the repo to e.g. C:\repo\ or something in similar length and try there.
    • if even that fails and the repo seems completely broken, I'd try cleaning up the repo by cloning it locally git clone ./repo newrepo and retry the push from within the new repo clone