I have an already initialized git repo that I added a .gitignore file to, how can I refresh the file index so the files I want ignored get ignored?
+1
A:
If the files are already in version control you need to remove them manually.
Aragorn
2009-07-16 19:28:57
+16
A:
Just got the answer from the IRC channel.
Running command:
git rm -r --cached .
This removes everything from the index, then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"
trobrock
2009-07-16 19:32:50
be aware to commit all your changes before, otherwise you will loose control on all the changed files
sfa
2010-01-13 14:48:19
This doesn't seem to stay on a push or a clean clone. any ideas?
BenB
2010-05-21 06:02:33
+10
A:
Yes - .gitignore system only ignores files not currently under version control from git. I.e. if you've already added a file called test.txt using git-add, then adding test.txt to .gitignore will still cause changes to test.txt to be tracked. You would have to git-rm test.txt first, commit that change. Only then will changes to test.txt be ignored.
Antony Stubbs
2009-07-18 08:15:31
+2
A:
To untrack a file that has already been added/initialized to your repository, ie stop tracking the file but not delete it from your system use: git rm --cached filename
pagetribe
2010-09-14 23:55:15