3

On macOS, if you change a folder's icon, a file called "Icon\r" (carriage return) is created inside that directory. Now I don't know how to exclude it from git. Listing it as "Icon?" works, but that would also match "IconF" or anything like this.

Is there any escape sequence git understands in .gitignore files to match exaclty that character?

Bachsau
  • 1,213
  • 14
  • 21

2 Answers2

2

The short answer is no, you can't do this properly.

There is no encoding available, which is unfortunate since it's possible to have newlines in file names and .gitignore cannot express this. Just as bad, if a line in .gitignore ends with a literal carriage return, the carriage return character is removed. So you could ignore a file named IconENTERX by typing that into an editor that allows you to embed ENTER (or Return depending on how your keys are labeled) characters (e.g., via CTRLVENTER in vim), but not IconENTER.

You can get close enough, probably, for practical purposes by listing Icon? followed by !Icon[A-Z] or similar.

torek
  • 448,244
  • 59
  • 642
  • 775
1

The same question has been asked at How to ignore Icon? in git. And users have given the answers that amtch your specific requirement.

https://stackoverflow.com/a/42369463/1281089

For me this worked in TextMate: Icon

https://stackoverflow.com/a/33974028/1281089

"Icon[\r]" is probably a better alternative.

https://stackoverflow.com/a/30755378/1281089

printf "Icon\r\r" > .gitignore

Ishan Thilina Somasiri
  • 1,179
  • 1
  • 12
  • 24