When using git on Mac OSX and your project’s folder has a custom icon, you will see a “Iconr” File showing up in your git status or Source Tree. Ignoring this file doesn’t work.
The solution is to ignore the correct way (or syntax), because Apple uses ^M at the end of the filename, which is a CRLF, a hidden character. In fact you have to ignore “Icon^M^M” in your .gitignore file, but it’s not easy to enter these special characters as ^M is in fact one single CRLF character.
I found a hint using the ruby interactive interpreter, but i wanted to use my beloved Python, so here’s the code:
>>> f = open('.gitignore','a') >>> f.write('Icon\r\r') >>> f.close()
use this in your home directory as you need to edit ~/.gitignore and ~/.gitignore_global (for Source Tree)
Take it one step further place a .gitignore’ file wihitn a directory (example: images/useruploads) and ignore the directory EXCEPT for the .gitignore placed wihitn that directory. This way, when someone pulls your repo, it will create the directory for them but not include all of the files along side.The idea is, there must be at least one file wihitn the directory in order for GIT to create the directory.