raxacoricofallapatorius raxacoricofallapatorius - 1 year ago 116
Git Question

Ho do I track only specific files using .gitignore?

What should I put in my Git repository's

to exclude all files and directories there except specific ones. For example if I have a large number of files and directories in a repo, and just want Git to track
, and
, but completely ignore everything else, what should be in my

Answer Source

You should ignore content; but exclude folders.
That allows you to exclude files.


That is because:

It is not possible to re-include a file if a parent directory of that file is excluded.

Check the effect of a .gitignore with git checkignore -v

git check-ignore -v -- afile
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download