Dealing with Mac OSX directory icon and attribute files in git
1: Write code
2: Use a Mac
3: Use git for version control
…then you likely will contaminate one of your repos with a slew of files named “Iconr” and .DS_Store at some point in your development cycle. Often it takes people a while to realize that the Icon files aren’t actually named Iconr, but are named Icon with special carriage return characters appended to the end of them. You’ll see them represented in a shell as
Icon\r\r depending on what tool you’re using.
Here is the cleanest way to prevent you from dealing with this issue across your projects.
Edit your personal global git ignore file:
Add an entry to prevent grabbing the .DS_Store files:
Add an entry to prevent grabbing the “Icon” file on any folders using custom display icons in Finder:
The final result will look like this:
But note that is NOT a caret-symbol and M there, so don’t just copy/paste it! Use the keystrokes above in vi/vim to create a proper carriage return character inside the brackets!