2016-12-14 34 views
1

我想從一個遠程存儲庫獲取一個目錄,但我只想從特定的散列獲取該文件。如果我使用HEAD的git壓縮文件,一切正常,但是當我嘗試使用特定的哈希值時:git歸檔從遠程的特定散列

git archive -v --format tar --remote = ssh://....myrepo.git agithash afile> output.tgz

但是我卻越來越

fatal: sent error to the client: git upload-archive: archiver died with error 
remote: fatal: no such ref: 9a9c309 
remote: git upload-archive: archiver died with error 

所以我讀過,我可以用另一種上傳存檔這樣的:

git的存檔-v --format焦油 - remote = ssh:..... myrepo.git --exec =「/ usr/local/bin/git upload-archive」ahas h afile> output.tgz

它也沒有工作。我認爲是因爲BitBucket不支持它按照https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html

所以我想知道:是否有另一種簡單的方法來做到這一點?

回答

0

如果承諾是由一個分支引用,你可以在合適的直接做一淺克隆承諾:

git clone <url> --depth=1 --branch <branch_name> -- <folder_name> 

然後產生一個存檔。

但是您不能directly get or clone a specific commit,出於安全原因。