2012-12-06 8 views
19

私は通常、指定した宛先にアーカイブを得るために、私project.git内の以下のコマンドを使用します。Git:リモートリポジトリから直接アーカイブする方法は?

git archive master | tar -x -C /home/kave/site/ 

その可能ならば、私が代わりに先のディレクトリにリモートリポジトリから直接アーカイブするだろうか?

私は喜びなしで、このような何かを試してみました:

git archive master https://[email protected]/myoproject.git | tar -x -C /home/kave/site/ 

任意の提案ですか? git help archiveから感謝

+0

Gitリポジトリを1.9/2.0(Q1 2014)浅いクローニングとはるかに効率的になります。http://stackoverflow.com/a/21217267/6309とhttp://stackoverflow.com/a/21217326/6309 – VonC

答えて

26

--remote=<repo> 
     Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository. 

コマンドは次のように終わる必要があります。

$ git archive --remote=https://[email protected]/myoproject.git master 

しかし、あなただけのレポを抽出したい場合は、あなたはgit clone--depthパラメータを使用して、浅いクローンを作ることができます。

--depth <depth> 
     Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. 

したがって、y OUはこのようなものがあります:

$ git clone --depth=1 https://[email protected]/myoproject.git 
+0

マスターではなく特定のタグを 'git clone --depth = 1'にする方法はありますか? – robru

+7

@Robru:それは独立した質問に値すると思うが、 'git help clone'の' - [no-] single-branch'について読む。 'git clone --depth = 1 --single-branch --branch TARGET_BRANCH REMOTE_URL'のようなものだと思います。そして、ありがとう - 私はそれについて前に考えなかった:) – mgarciaisaia

関連する問題