7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git で clone せずに特定のファイルを取り出したい

Last updated at Posted at 2015-04-24

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
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?