git で clone せずに特定のファイルを取り出したい
追記:
書いた後に調べたらgit archive
でできそう。
https://www.glpgs.com/e-blog/archives/175
けど、sha1でのコミット指定はできないっぽい。
駄目
git archive --remote ssh://some_repos.git 9ad97486f5d75898af6a8a706db43f579df38300:app/modules/ | tar x
ブランチかタグ指定じゃないと駄目なのかな。
https://confluence.atlassian.com/display/STASHKB/git+upload-archive+archiver+died+with+error
要fetch
sha1で特定のコミット指定して落としてくるならこうかな?
git_partial_export.sh
# !/bin/bash
# 出力するダミーのリポジトリ
git init /tmp/partial_export
cd /tmp/partial_export
# 参照したい remote を追加
git remote add another ssh://some_repos.git
git fetch another
# 取り出したいファイルとかフォルダとか
git config core.sparsecheckout true
echo "app/modules/lib" > .git/info/sparse-checkout
# コミットを指定して取り出す
git read-tree -m -u 310ba582c49637d4a14da9ad23af04d0ef0e1a62
# かくにん
tree /tmp/partial_export