Remove weird 'Iconr' file from the repository
Adding a line
Icon?
to .gitignore worked for me.
https://answers.atlassian.com/questions/167170/removing-invisible-icon-files-on-a-local-repository-on-a-mac
It is best to revert to the command line in order to have a more precise error message.
There you can try a git add -u
, followed by a git commit
, in order to register the deletion of that file in the repo.
See "git status
says file is deleted but git rm
says error: pathspec '…' did not match any files
" as an example.
You can also preview what a git clean would give: git clean -d -x -n
(as explained in "Why is there no “pathspec” when I try to remove a folder in Git?")
The other issue is when that file isn't tracked at all in your current branch, but is tracked in another branch. See that answer to check if that is the case.
The Icon^M
-like files most likely are created by some external apps such as Folderol which are highlighting your folders.
You should either remove the app which is doing that, or ignore it in your .gitignore
file, e.g.
printf "Icon\r\r" >> .gitignore
This is a shell command. Or add it as Icon??
or you can reproduce ^M
special character by Control-V and hitting Enter.
Related: How to ignore Icon? in git
If you don't want to commit this change into your repository, alternatively add it into your global .gitignore
or add it into .git/info/exclude
.
See: Using Git / Ignoring files.
To remove the files it-self, try:
find . -type f -name 'Icon?' -print -delete
Or if they're the only one which are unstaged, run: git clean -f
.
As a general workaround the .gitignore
file can be edited to completely ignore the Icon\r
files as described in this blog entry: Git Tip: Ignoring Icon\r in .gitignore