git从远程的特定散列归档 [英] git archive from a specific hash from remote

查看:197
本文介绍了git从远程的特定散列归档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从一个远程存储库获取一个目录,但我只想从特定的散列获取该文件。如果我用HEAD使用git archive,一切正常,但是当我尝试使用特定的散列时:

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



但是我得到了

  fatal:向客户端发送错误:git upload-archive:archiver死于错误
remote:fatal:没有这样的ref:9a9c309
remote: git upload-archive:archiver死于错误

所以我读过我可以使用另一个上传 - 像这样归档:



git archive -v --format tar --remote = ssh:..... myrepo.git --exec =/ usr / local / bin / git upload-archiveahash afile> output.tgz



它也不起作用。我认为是因为BitBucket不支持它按照 https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html



所以我想知道:是否有另一种简单的方法来做到这一点?

解决方案

直接在正确的提交处做一个浅层克隆:

  git clone< url> --depth = 1  - 分支< branch_name> - < folder_name> 

然后进行归档。



但出于安全原因,您无法直接获取或克隆特定提交


I am trying to get one directory from one remote repository but I only want to get that file from a specific hash. If I use git archive with HEAD everything is OK but when I try with a specific hash:

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

But I'm getting

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

So I've read that I could use another upload-archive like this:

git archive -v --format tar --remote=ssh:.....myrepo.git --exec="/usr/local/bin/git upload-archive" ahash afile > output.tgz

It didn't work either. I assume is because BitBucket does not support it as per https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html

So I wonder: is there another simple way to do this?

解决方案

If that commit is referenced by a branch, You could do a shallow clone directly at the right commit:

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

And then make an archive.

But you cannot directly get or clone a specific commit, for security reason.

这篇关于git从远程的特定散列归档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆