EAS Build error: git exit with non-zeo code: 128

I struggled with the error shown in the title and found a solution to it so I just wanted to share in case someone comes across the same situation as me.

Problem:
EAS Build during the stage ‘compressing project files’. It returned ‘git exited with non-zeo code: 128

Posts that I came across & tried:
It looks like I can only upload 2 links at most so here’s what you could try first

eas-cli/repository.ts at e71779049e3e9e19613c4e187754fabe31062d4c · expo/eas-cli · GitHub (read through how the compression is done and tried the individual steps 1 by 1)

But none of the posts online helped me. Even ‘git clone --no-hardlinks --depth 1 <GIT_PATH> <TEMP_PATH>’ was working fine.

My Solution:
If none of the above solutions worked, try this too

  1. cd into the ‘android’ folder (even though it’s the iOS build that doesn’t work)
  2. run ‘gradlew clean’
  3. try running the eas build again and it works