knuton knuton - 2 months ago 10
Git Question

Keep ignored files out of git status

I would like to stop Git from showing ignored files in

git status
, because having tons of documentation and config files in the list of Changed but not updated files, renders the list half-useless.

Is it normal for Git to show these files?

I put the ignore information in a
.gitignore
file in the root directory of the Git repository and they are not added when using
git add .
but it seems that they are not fully ignored either, as they show up in the aforementioned list and do not show up in the list printed by
git ls-files --others -i --exclude-standard
. Only files matched by the patterns in
~/.gitignore
show up there.

Could it be because at an earlier stage I didn't ignore them and they were thus committed at least once?

MBO MBO
Answer

As I found in this post, .gitignore only works for untracked files. If you added files to repository, you can:

git update-index --assume-unchanged <file>

or remove them from repository by

git rm --cached <file>

Edit

This article explains that too