I am getting my feet wet with Git and have the following issue:
My project source tree:
/
|
+--src/
+----refs/
+----...
|
+--vendor/
+----...
I have code (currently MEF) in my vendor branch that I will compile there and then move the references into /src/refs
which is where the project picks them up from.
My issue is that I have my .gitignore
set to ignore *.dll
and *.pdb
. I can do a git add -f bar.dll
to force the addition of the ignored file which is ok, the problem is I can not figure out to list what files exist that are ignored.
I want to list the ignored files to make sure that I don't forget to add them.
I have read the man page on git ls-files
and can not make it work. It seems to me that git ls-files --exclude-standard -i
should do what I want. What am I missing?
Best Solution
Notes:
git status --ignored
(as detailed in "Is there a way to tell git-status to ignore the effects of
.gitignore
files?")git clean -ndX
works on older gits, displaying a preview of what ignored files could be removed (without removing anything)Also interesting (mentioned in qwertymk's answer), you can also use the
git check-ignore -v
command, at least on Unix (doesn't work in a CMD Windows session)The second one displays the actual rule of the
.gitignore
which makes a file to be ignored in your git repo.On Unix, using "What expands to all files in current directory recursively?" and a bash4+:
(or a
find -exec
command)Note: https://stackoverflow.com/users/351947/Rafi B. suggests in the comments to avoid the (risky) globstar:
Make sure to exclude the files from the
.git/
subfolder though.CervEd suggests in the comments, to avoid
.git/
:Original answer 42009)
should work, except its source code indicates:
exc_given
?It turns out it need one more parameter after the
-i
to actually list anything:Try:
(but that would only list your cached (non-ignored) object, with a filter, so that is not quite what you want)
Example:
Actually, in my 'gitignore' file (called 'exclude'), I find a command line that could help you:
So....
should do the trick.
(Thanks to honzajde pointing out in the comments that
git ls-files -o -i --exclude-from...
does not include cached files: onlygit ls-files -i --exclude-from...
(without-o
) does.)As mentioned in the ls-files man page,
--others
is the important part, in order to show you non-cached, non-committed, normally-ignored files.--exclude_standard
is not just a shortcut, but a way to include all standard "ignored patterns" settings.