git archive を使ってリリース用ファイルをエクスポートする

/var/tmp/junk にファイルをエクスポートする。

$ git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

エクスポートしたくないファイルがあるときは .gitattributes に書いて、git archive 時に --worktree-attributes オプションを付ける。

$ vim .gitattributes
.gitignore export-ignore
Makefile export-ignore

$ git archive --worktree-attributes --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

参考

Git - git-archive Documentation