Sangam Gupta
Sangam Gupta

Reputation: 111

How can I see list of ignored files in git?

I have been using git from past few months and I like git. I was wondering if there is a command which can show list of ignored files in a project.

I tried this git status --ignored from root directory of the project but it doesn't seem to be sufficient.

Upvotes: 7

Views: 6220

Answers (4)

Sberm
Sberm

Reputation: 1

use git check-ignore, pipe the stdin into it using find.

find ./ -regex ".*" | git check-ignore --stdin

Upvotes: 0

  1. find -type f | git check-ignore --stdin gives all files ignored in whole repo (and if you have some in .git that fit, it will report them too).
  2. git ls-files --exclude-standard --ignored --others - gives ignored file per current directory (not whole repository).

Both solutions honor not just top-level .gitignore file, but also global one, .git/info/exclude and local (in lower-level dirs) .gitignores

Upvotes: 6

Atropo
Atropo

Reputation: 12531

You can use the clean command with the option:

-n, --dry-run - Don't actually remove anything, just show what would be done

git clean -ndX 

In this way git will list all the files that would be cleaned without doing anything, and you get a list of ignored files.

Upvotes: 7

Damien
Damien

Reputation: 1209

You can edit the .gitignore file found in the same directory as your .git folder if you are looking for a list of files to ignore (listed on each line as regular expressions).

Example:

cat .gitignore

might show:

^build$ 
^build[/].
*-objs/ 
.project
*~

Upvotes: 1

Related Questions