git归档命令与bitbucket [英] git archive command with bitbucket

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

问题描述



我试图使用git archive命令与bitbucket



有什么想法?



git archive --remote = ssh://git@bitbucket.org/username/reponame.git --format = tar --output =file.tar



我创建了所有的SSH密钥和公钥等,甚至测试了ssh -v hg@bitbucket.org并且它工作正常

解决方案

当您使用 - remote


$时,您无法获得仅存档而无需精简树的存档b $ b

  git archive --remote = ssh://git@bitbucket.org/username/reponame.git --format = tar --output =file.tar master 

可以工作,提到一个分支名称。也有一个标签的名字。



但是,根据这个线程,提交ID不会工作:


是否有原因 git-archive 需要一个名为ref而不仅仅是一个提交(或树) ID?



是;通常git存储库不允许客户端访问任意sha1。相反,它们要求所请求的对象可以被ref访问。



git-archive 没有正确执行此操作,并且最近更改为只允许通过名称引用引用,以及引用子树(例如 HEAD:subdir / )。

意味着我们不允许任意提交或树sha1,即使它可以从广告的引用中获得。


难以修补git -upload-archive使用ID?

我可以使用标签作为ref,但在我的情况下会导致几乎所有的commit都是一个看起来很浪费的标签。


正确的做法有点贵,因为在一般情况下(有人要求树sha1),我们需要遍历每个提交的每棵树,看它是否是

我们可能会实现一组更加有限的规则,允许< commit>:< subdir> 并检查< commit> 是可达的。

这将禁止任意树sha1,但我怀疑它会覆盖常见的
用例(即,你想获得特定版本的树,甚至是子树)。



I' using windows, git bash prompt

I'm trying to use the git archive command with bitbucket

and I receive the error remote: "git upload-archive: archiver died with error"

Any ideas ?

git archive --remote=ssh://git@bitbucket.org/username/reponame.git --format=tar --output="file.tar"

I have created all SSH keys and public keys etc and even tested ssh -v hg@bitbucket.org and it works fine

解决方案

You cannot get just an archive without precising the tree-is you want to get, when you are using --remote

git archive --remote=ssh://git@bitbucket.org/username/reponame.git --format=tar --output="file.tar" master

Would work, mentioning a name of a branch.
That would work too with the name of a tag.

However, according to this thread, a commit ID would not work:

Is there a reason git-archive requires a named ref rather than just a commit (or tree) ID?

Yes; generally git repositories do not allow clients to access arbitrary sha1s. Instead, they require that the requested objects be accessible by a ref.

git-archive was not properly enforcing this, and was changed recently to allow only refs by name, as well as sub-trees of refs (e.g., HEAD:subdir/).
That means we do disallow an arbitrary commit or tree sha1, even if it is reachable from the advertised refs.

would it be difficult to patch git-upload-archive to use the IDs?
I could use tags for the ref, but in my case would result in almost every commit being a tag which seems wasteful.

Doing it right is a bit expensive, because in the general case (somebody requested a tree sha1), we would need to traverse every tree of every commit to see if it is reachable.

We could potentially implement a more restricted set of rules, allowing "<commit>:<subdir>" and checking that <commit> is reachable.
That would disallow an arbitrary tree sha1, but I suspect it would cover the common use case (i.e., you want to get the tree, or even a subtree, of a particular revision).

这篇关于git归档命令与bitbucket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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