git fatal: pack has 1 unresolved delta (index-pack failed)

I have a VERY strange and not so covered issue with a specific Windows Build Server (Jenkins Slave).

In Jenkins I have a Job that pulls the latest code from a specific branch.

The actual command the git is trying to execute is:

git fetch -t origin +refs/heads/*:refs/remotes/origin/*

Before few hours, after working well for 1 month, suddenly the Job fails with this error:

ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\bin\git.exe fetch -t origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: pack has 1 unresolved delta
fatal: index-pack failed

I tried to find some posts about it over the web, but nothing came up...

Things I already tried:

  1. Uninstall git and install again
  2. Delete the workspace (which is deleted also by the job as the wipe out option is chosen"
  3. Delete ALL the workspace from the system
  4. git fsck - No interesting results
  5. git verify-pack - No interesting results
  6. git index-pack + the relevant pack file - No interesting results here as well

Some more (hopefully important) information:

  1. From this Server, when I am working via CMD / GitBash - The same issue persist
  2. From other Servers / PC, I am able to execute this command with the same git Repo that makes me troubles...
  3. Other tasks that work with different Git Repo on the SAME build Server works fluently.

I am LOST. Can someone shed some light on this?


Solution 1:

The Root Cause for all this mess is still unknown for me.

But now I managed to overcome it this way:

In the Jenkins Job, under the Git SCM configuration the following lags were on:

  1. Wipe out workspace before build
  2. Use shallow clone

Removing the 2 of them solved the problem.

Afterwards, it is possible to put them back and it will still work.

WEIRD!!!

Solution 2:

A reason I had this problem was the git clone was done 'shallow' hence it didn't have the full history of commits (hence fetch couldn't see the full history to calculate deltas).

Check Git log in the working tree you're trying to fetch into, it shouldn't have full history - mine had only a few commits listed with the oldest one on the list was saying it was adding a 'new file' for all the files in the repo - a squashed one I think.

Make sure no GIT_DEPTH variable is set, then

git pull --unshallow

or

git pull 

and try fetch again.