How to I add something to the .gitignore so that the match is not recursive?
How to I add something to the .gitignore so that the match is not recursive? For example, I wish to ignore the directory foo and the file bar.txt in the current directory, but not any that exist in subdirectories. I have tried this for my .gitignore file: foo/ bar.txt But unfortunately git applies this recursively, so that otherdir/bar.txt and otherdir/foo/ also get ignored, which is not what I want. (Is there a command in git that shows me all ignored files, and reference the .gitignore file that is responsible for the file being ignored? This would be useful for debugging.) The solution is