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
If you want to package up files for deployment, you probably don't need - or want - the repo itself. This is exactly what git archive is for. A couple examples from the manpage (linked):
git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)
Create a tar archive that contains the contents of the latest commit on the current branch, and extract it in the /var/tmp/junk directory.
git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip > git-1.4.0.tar.gz
Create a compressed tarball for v1.4.0 release.
You ought to be able to get it to do exactly what you want, with the help of the export-ignore
attribute:
export-ignore
Files and directories with the attribute export-ignore won’t be added to archive files. See gitattributes(5) for details.
For example, to exclude the directory private
and the files mine.txt
and secret.c
, you could put in the file .gitattributes
:
private/ export-ignore
secret.c export-ignore
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.