.gitignore is ignored by Git

前端 未结 30 1408
梦毁少年i
梦毁少年i 2020-11-22 02:51

My .gitignore file seems to be being ignored by Git - could the .gitignore file be corrupt? Which file format, locale or culture does Git expect?

30条回答
  •  再見小時候
    2020-11-22 03:34

    My issue was (as OP suggested) a corrupt .gitignore file. I didn't believe that it was and ignored the possibility until everything else failed. The corruption didn't show up in vi, but there were two bytes on the start of the file that caused the .gitignore file to be ignored. For me, these only showed up when I typed cat .gitignore, which showed:

    ��# Built application files
    *.apk
    *.ap_
    
    # ...
    

    I have no idea how these ended up there, but recreating the file fixed the issue. A hex analysis of the corrupt file showed the following:

    user@dev ~/project/myproject $ xxd -b .gitignore
    00000000: 11111111 11111110 00100011 00000000 00100000 00000000  ..#. .
    00000006: 01000010 00000000 01110101 00000000 01101001 00000000  B.u.i.
    

提交回复
热议问题