Question

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?

Was it helpful?

Solution

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

OTHER TIPS

I've had this issue come up as well, it's probably because you added your ignored directory/files to .gitignore after they were marked as "to be tracked" by GIT in an initial commit flow.

So you need to clear the git tracking cache like so:

git rm --cached -r [folder/file name]

A more detailed explanation can be read here: http://www.frontendjunkie.com/2014/12/stop-git-from-tracking-changes-to.html

The above command also removed the remnants of the folder/files from your remote GIT origin. So your GIT repos become clean.

Problem can be that this file is still in the git cache. To solve this problem needs to reset git cache.

Reset git cache. This removes everything from the index.

git rm -r --cached . 

Add all files again:

git add . 

Commit:

git commit -m ".gitignore was fixed." 

This surely works,

git rm --cached -r [folder/file name]

I assume you want not to add tmp directory (Visual Studio Platform)

1- add lines below to your local .gitignore file

## ignore tmp
/tmp/
./tmp/

3- backup and delete tmp Folder locally. (Backup somewhere else. eg desktop?)

4- Commit Changes to Local than Sync to Remote (eg. github).

After these steps your tmp directory wont be uploaded again.

From man git-lsfiles:

-i, --ignored
Show ignored files in the output. Note that this also reverses any exclude list present.

Personally I tend to keep doxygen files in my source tree, so I simply added this to my .gitignore (which is in the topmost directory of my source tree):

docs/*

Hope that helps.

Following steps work for untracked files only. This info is applicable for following configuration:

Platform: linux

Git version: git version 1.8.3.1

Put list of files to be ignored in "exclude" file present at following location.

<path till .git directory>/.git/info/exclude

Initial content of "exclude" file

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

Final content of "exclude" file

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~


*.tar
*.gch

like this

git --ignored myfolder

And will show status only for myfolder

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top