Reputation: 2964
I don't want my MacBook's .DS_Store-files to be committed to my Git repository.
Unfortunately my .gitignore and even .gitignore_global seem to be ignored completely.
Any ideas what could be the reason?
ujjain:~/Dropbox/workspace| (HEAD) [+1] | feature/Jenkinsfile [+1]
$ cat .gitignore
...
# Mac OS Test
.DS_Store
ujjain:~/Dropbox/workspace| (HEAD) [+1] | feature/Jenkinsfile [+1]
$ git status
On branch feature/Jenkinsfile
Your branch is up to date with 'origin/feature/Jenkinsfile'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .DS_Store
no changes added to commit (use "git add" and/or "git commit -a")
Upvotes: 1
Views: 3306
Reputation: 4476
Your .DS_Store
has been committed before it had been added in the .gitignore
. You remove it from your repo with:
git rm --cached .DS_Store
git commit -m '.DS_Store untracked'
The --cached
option will remove the file from the index only, but will not delete the file itself.
Once this will be done, the file will not be tracked by Git anymore and will be properly ignored.
Upvotes: 6
Reputation: 101
You may have committed this file previously. Try this to remove it:
git rm --cached .DS_Store
Upvotes: 5