If I don’t want .html files tracked I can add the pattern to .gitignore and they’ll be ignored. I’d like to know how I can do the converse – at checkout, how could I ask git to only checkout certain types of files or not checkout certain types of files?
For example, if I didn’t want html files I could write:
git checkout HEAD . --no .html
if that existed. Is there a way already built in, or do I just have to run something else post-checkout?
If you want to package up files for deployment, you probably don’t need – or want – the repo itself. This is exactly what
git archiveis for. A couple examples from the manpage (linked):You ought to be able to get it to do exactly what you want, with the help of the
export-ignoreattribute:For example, to exclude the directory
privateand the filesmine.txtandsecret.c, you could put in the file.gitattributes:Just like gitignore files, you can put those anywhere in your repository, and they’ll operate from that directory, but starting from the top level is a good bet.