I have modified my .gitignore
file to keep it cleaner, but I expect it has the same behaviour than previously and I would like to check that it would not ignore any of my already tracked files. How can I check it? Is there some way to list the tracked files that would be covered by the current .gitignore
rules (so ideally this list would be empty)?
Thanks!
CodePudding user response:
If you want to display all files in the repo which are ignored (but, as eftshift0 rightfully notes, are therefore not tracked), you can do
$ git ls-files -oi --exclude-standard
Comparing what you get from that command alternatively with your old and new .gitignore
files can be a good troubleshooting step. Also note that you can git check-ignore -v <path/to/some/file>
to debug some specific file and see where the ignoring comes from (in case of multiple nested ignore files)
CodePudding user response:
Once you already have some tracked files, and then you add them to gitignore
file, git
will not forget about them. So you need to explicitly untrack them, as described in this thread - How do I make Git forget about a file that was tracked, but is now in .gitignore?.
And overall, you could list all ignored file using this command (https://gist.github.com/naholyr/1836765#file-git-ignored-sh)
git ls-files --others --ignored --exclude-standard