How to fix "warning: ignoring ref with broken name" in git?

I am working on OSX. In a specific repo, when I type autocomplete after entering the git command:

$ git diff [clicks tab...] 

Now I see a huge amount of warnings:

 warning: ignoring ref with broken name refs/Icon warning: ignoring ref with broken name refs/heads/Icon warning: ignoring ref with broken name refs/remotes/Icon warning: ignoring ref with broken name refs/remotes/origin/Icon warning: ignoring ref with broken name refs/tags/Icon 

This is really annoying, and that means that I cannot see the names of the files I want to see.

How to remove or nip these warnings?

Do I have an entry for Icon? in my gitignore file. Is there an Icon? file in the local directory Icon? .

For all people with a trigger who want to click β€œduplicate”: I was looking for other answers, I found this , but I'm not sure how to do this applies to my situation. Maybe the main reason is the same, but it would be helpful for me, and others to explain how to fix this problem.

+7
git
source share
1 answer

The Icon\r file is created by Mac OS when the folder icon changes .

How to remove or nip these warnings?

You need to delete the offending files themselves.

Do I have an entry for Icon? in my gitignore file.

It does not matter. A .gitignore runs in a working directory; these files are located inside the repository folder where Git stores its metadata. .gitignore does not apply there. Git accepts them as branch names.

To fix this problem, you can delete the custom icon that you specified in your folder. But if not, you will need to delete the files from the .git folder. You can do this in the Finder (after enabling "Show hidden files") or from the command line:

 rm .git/refs/Icon? 

Be sure to back up your repository before attempting to do this , as a change in the .git folder may damage your repository.

+5
source share

All Articles