けれど .gitignore とかはアーカイブにはいらないのでどーにかできないかな、と思っていると tar とかでフィルタする 方法があるらしい。
けれど Mountain Lion にデフォルトで入っている tar には --delete オプションが無い様子。
で、もう少し調べると .gitattributes なるものがある様子。
これを書いているとファイルに対していろいろと設定できるらしく、 export-ignore と書いているとarchiveに含まれなくなるみたい。
.gitignore 除外のための .gitattributes の例はこんな感じ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.gitignore export-ignore |
$ git archive HEAD -o archive.tgz
だと除外されずに変わらない。
$ git archive
を打つと --worktree-attributes なるオプションがあるらしいので、これを付けるとちゃんと 除外された。
なので
$ git archive HEAD --worktree-attributes -o archive.tgz
とかするとOK。
それで、.gitattributes の試しに作ってみたのが このリポジトリ。
.gitignore と include.txt と exclude.txt と archive.sh があって、.gitignore と exclude.txt は .gitattributes で export-ignore してる。
archive.sh を走らせると archive.tgz ができる。
解凍して中を見ると、include.txt と archive.sh しか入っていないはず。
実際にどのコマンドが走ってるのは archive.sh を見てみてください。
これで archive に必要無いファイルをgitできちんと管理しながら git archive から除外できそう。