Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

I'm working on OSX. In a particular repo, whenever I tab to autocomplete after typing a git command:

$ git diff [clicks tab...]

I now see a huge number 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

It's really annoying, and it means that I can't see the filenames I want to see.

How can I remove or suppress these warnings?

I have an entry for Icon? in my gitignore file. There is an Icon? file in the local directory.

For all the trigger-happy people about to click "duplicate": I've searched for other answers, I found this but I'm not sure how it relates to my situation. It may be that the underlying cause is the same, but it would benefit me and others to have an explanation of how to fix this problem.

like image 846
Richard Avatar asked Jan 25 '16 10:01

Richard


1 Answers

The Icon\r file is created by Mac OS when you change a folder's icon.

How can I remove or suppress these warnings?

You need to delete the offending files themselves.

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

That makes no difference. A .gitignore works on the working directory; these files are inside the repository folder where Git stores its metadata. .gitignore does not apply there. Git is mistaking them as branch names.

To fix this problem, you may be able to remove the custom icon you gave your folder(s). But if not, you will need to remove the files from beneath the .git folder. You can do this in Finder (after turning on "Show Hidden Files") or from the command line:

rm .git/refs/Icon?

Make sure to backup your repository before attempting this as changing things in the .git folder can corrupt your repository.

like image 65
Edward Thomson Avatar answered Oct 26 '22 19:10

Edward Thomson