I have a file mentioned in .gitignore, but I added it by git add -f
because I wanted to add
it only once and then ignore it as usual.
However, it is now tracked by default. How do I undo this?
I have a file mentioned in .gitignore, but I added it by git add -f
because I wanted to add
it only once and then ignore it as usual.
However, it is now tracked by default. How do I undo this?
Not completely sure what you're looking for but you can either remove the file to be ignored in future commits with
git rm --cached filename
Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename
Info: https://help.github.com/articles/ignoring-files
Or you can tell git that it ignores the changes of a file with
git update-index --assume-unchanged filename
and undo it with
git update-index --no-assume-unchanged filename
To list all assume-unchanged files run
git ls-files -v|grep '^h'
Info: How do I .gitignore and delete an already committed file without affecting other working copies?
However please keep in mind that assume-unchanged is (in my opinion) against the philosophy of git and this command will only ignore it the changes made on your machine. Everyone else will still be able to overwrite it.
In most cases you use this for configuration files. What you can do to avoid using this option is to keep it in the .gitignore and add a setup description to the README or create a little setup script which creates those files.