【发布时间】:2015-05-08 22:54:35
【问题描述】:
当我尝试从不同目录在本地存储库上运行 git archive 时
git archive --format=tar.gz --remote=file:///home/user/repos/repodir --prefix=/tmp/test_archive -o archive.tar.gz ref12345
此命令失败,输出如下。似乎不接受远程选项。
remote: fatal: no such ref: ref12345
fatal: sent error to the client: git upload-archive: archiver died with error
remote: git upload-archive: archiver died with error
当我切换到 repo 目录并在没有远程选项的情况下执行时,它很好。即
cd /home/user/repos/repodir
git archive --format=tar.gz --prefix=/tmp/test_archive -o archive.tar.gz ref12345
使用的 --remote 语法是否存在缺陷,或者本地存储库不支持 --remote 选项?
【问题讨论】:
-
你用的是什么版本的git?我使用的是 2.3.1,使用
--remote=file://...和--remote=/path/to/repo可以正常工作。错误消息似乎表明 ref 有问题。我尝试在 git repo 之外运行它,并在另一个不相关的 repo 中运行它,请求当前 repo 中不存在的标签,并且一切都按预期工作。 -
我的 git 版本是
1.9.1这是发行版的默认版本,Trusty Tahr -
有趣。我想知道您尝试此操作时是否拼写不正确。我没有看到任何涉及您的版本和我的版本之间存档的错误修复。 :-( 除了所有这些之外,git 确实支持将
git archive与 file:// urls 和 /paths 一起使用。 -
独立的 SHA 不是一个有效的 treeish,还是我也必须指定一个分支? Git repo 是 main repo 的镜像,它为编译而刷新,默认分支是上游。有没有可能是问题所在。我认为只要 ref 出现在 git 日志中,它就应该可用于
git archive或者我错过了一些关键的 git 概念 -
是的,提交的 SHA1 是一个有效的 treeish。你没有说那是你正在使用的东西。我假设你上面的输出被修改了,所以我真的不知道发生了什么。但是一个简单的拼写错误可能是问题所在。无论哪种方式,都支持您想要做的事情,因此要么是用户错误,要么是您的存储库发生了一些奇怪的事情。
标签: git git-archive