从远程获取指定哈希值的git归档文件

7
我正在尝试从一个远程仓库获取一个目录,但我只想从特定的哈希值中获取那个文件。如果我使用带有HEAD的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 archive -v --format tar --remote=ssh:.....myrepo.git --exec="/usr/local/bin/git upload-archive" ahash afile > output.tgz

但它也没有起作用。我认为这是因为BitBucket不支持,就像https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html中所述。

那么,是否还有其他简单的方法来完成此操作呢?

1个回答

0
如果该提交被分支引用,您可以直接在正确的提交处进行浅克隆:
git clone <url> --depth=1 --branch <branch_name> -- <folder_name>

然后创建一个归档文件。

但出于安全考虑,您不能直接获取或克隆特定的提交


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接