.gitignore is ignored by Git

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

    If it seems like Git isn't noticing the changes you made to your .gitignore file, you might want to check the following points:

    • There might be a global .gitignore file that might interfere with your local one
    • When you add something into a .gitignore file, try this:

      git add [uncommitted changes you want to keep] && git commit
      git rm -r --cached .
      git add .
      git commit -m "fixed untracked files"
      
    • If you remove something from a .gitignore file, and the above steps maybe don't work,if you found the above steps are not working, try this:

      git add -f [files you want to track again]
      git commit -m "Refresh removing files from .gitignore file."
      
      // For example, if you want the .java type file to be tracked again,
      // The command should be:
      //     git add -f *.java
      

提交回复
热议问题