gitignore just doesn't work. I can't get it to ignore .DS_Store & .gitignore files

前端 未结 10 1918
一整个雨季
一整个雨季 2021-02-07 20:12

I have .gitignored .DS_Store and .gitignore files. But still see them in the \"git status\".

Can someone explain to me how I can m

相关标签:
10条回答
  • 2021-02-07 20:21

    If you want to ignore a change to a file that is tracked by git you can specify to git that it should assume that the file has not changed:

    git update-index --assume-unchanged file
    

    and to start tracking changes again do:

    git update-index --no-assume-unchanged file
    

    if you have already added a file that should be completely ignored (.gitignore) you have to git rm it first.

    reference: https://www.kernel.org/pub/software/scm/git/docs/git-update-index.html
    source: http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/

    0 讨论(0)
  • 2021-02-07 20:21

    I had an issue getting .DS_Store ignored where the problem was that it had already been committed to the repo. Removing it resolved the issue.

    $ git rm --cached .DS_Store
    
    0 讨论(0)
  • 2021-02-07 20:21

    I had the same exact issue on Mac OS X. I had .gitignore file in the repo but it just won't work.

    What was weird when I wanted to print the .gitignore content to the console with the cat command it printed as it was empty. When opened with vim it appeared as normal.

    The solution was to remove the file, create a new one and put the content into it again. After that, ignoring files started to work and when I done cat .gitignore it printed properly.

    0 讨论(0)
  • 2021-02-07 20:24

    This is what your .gitignore should look like:

    .DS_Store
    

    Also, the .gitignore is meant to be tracked, ignoring it doesn't make sense. So after you've updated the file to contain just .DS_Store do:

    $ git add .gitignore
    $ git commit -m "Track .gitignore"
    
    0 讨论(0)
  • 2021-02-07 20:26

    I faced the same problem. None of the .gitignore lines were in effect.

    I converted the file encoding into UTF-8 and it worked instantly.

    0 讨论(0)
  • 2021-02-07 20:28

    I experience the same issue. The solution is to add a .gitignore under your home directory first.

    My end the repository .gitignore no longer appears in indexing tracking.

    0 讨论(0)
提交回复
热议问题