4

My git gc is giving me errors:

error: bad ref for Icon
fatal: bad object refs/remotes/Icon
error: failed to run repack

I know those Icon files are connected with OS X's auto-created files. I have added them to .gitignore.

But they could have been committed before I did this.

I am the only one who commits / has copy to the repository.

Thank you.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Jav
  • 2,203
  • 13
  • 22
  • Theres a more detailed thread about this [here](https://stackoverflow.com/questions/17556250/how-to-ignore-icon-in-git) – user3623413 Jul 05 '22 at 15:30
  • @user3623413 while it is more detailed thread, it is about a slightly different topic. The problem described here is not about adding ?Icon into .gitignore (which is actually straightforward). But the issue that arises when it was not added at the beginning and they were created inside ref. In which cases adding it into gitgnore (in any million ways) won't solve the fatal error. – Jav Jul 08 '22 at 09:27

1 Answers1

11

Solved it.

Apparently OS X just created those files in ref folder and git was looking for them.

So I have used a command to find and recursively delete all Icon files:

find . -name "Icon?" -print0 | xargs -0 rm -rf

Source: Recursively Remove Icon? in Mac OSX.sh

Jav
  • 2,203
  • 13
  • 22
  • 4
    Somehow I need to do this everytime I do `git pull` and on every repo in my mac. This can't be normal ways of working. Is there any permanent solution? – vishwarajanand Jan 13 '22 at 19:59