Search code examples
gitgitignore

.gitignore does't ignore files properly


I have a github repository with a few .c, .s, .txt files, a Makefile and a .vscode and two .dSYM directories which have been created during debugging. I want to ignore these last three files. My .gitignore is the following:

*.vscode
*.dSYM

Both .dSYM files have a folder named Contents; my problem is that one (and only one!) of these folders is not ignored. Why does this happen? How can I solve this?

Link to my repository


Solution

  • You need to use a forward slash if you want git to ignore all the files inside the directory.

    /libasm.dSYM
    

    UPDATE

    And if you already git added some folders/files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them.

    git rm -r --cached .
    git add .
    

    Then commit your changes:

    git commit -m "Untrack files in .gitignore"