.gitignore is ignored by Git

前端 未结 30 2215
梦毁少年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:40

    I just ran into this issue. The content within my .gitignore file continued to appear in the list of untracked files.

    I was using this to create the ignore file:

    echo "node_modules" > .gitignore
    

    It turns out that the double quotations were causing the issue for me. I deleted the ignore file and then used the command again without quotes, and it worked as expected. I did not need to mess with the file encoding. I'm on a Windows 10 machine using Cmder.

    Example:

    echo node_modules > .gitignore
    

提交回复
热议问题