2012-12-06 104 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/ 

有什麼建議?由於

+0

GIT中1.9/2.0(Q1 2014)將大大淺克隆更有效:http://stackoverflow.com/a/21217267/6309和http://stackoverflow.com/a/21217326/6309 – VonC

回答

26

git help archive

--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 - 單分支 - 分支TARGET_BRANCH REMOTE_URL',我想。而且,謝謝 - 我從來沒有想過那樣:) – mgarciaisaia