为什么 GIT 报告“致命:此操作必须在工作树中运行”从裸仓库导出时?
如果我使用 git archive 命令从裸 GIT 存储库导出,我会收到错误消息: “致命:此操作必须在工作树中运行”,尽管导出正确通过。
所以我的问题是:从裸存储库导出时有什么问题吗?我检查了导出的存档,看起来没问题。
if I export from bare GIT repository using git archive command I get error message:
"fatal: This operation must be run in a work tree", altough the export passes properly.
So my question is: Is there any issue when exporting from bare repository? I checked the exported archive and it looks alright.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我实际上没有收到该警告 - 我相当确定这是一个错误,在您使用的版本之后的某个时间得到了解决。我无法准确说出具体时间,因为我什至根本没有设法重现它(我尝试了 v1.5.3.4、v1.6.2 和当前 master 的构建。)
I don't actually get that warning - I'm fairly certain it was a bug which was resolved sometime after the version you're using. I can't tell exactly when, because I haven't even managed to reproduce it at all (I tried v1.5.3.4, v1.6.2, and a build from current master.)
正如“备份使用git的项目”中提到的,
git 包
会更合适。但您可能需要一份简单的副本,而不是捆绑在一个文件中的所有历史记录。
话虽这么说,如果 git archive 需要一个工作树(如“如何进行 Git 导出"),其错误消息预计出现在裸存储库中,根据定义,该存储库没有工作目录。
As mentioned in "backing up project which uses git",
git bundle
would be more appropriate.But you may be after a simple copy, and not the all history bundled in one file.
That being said, if
git archive
expect a working tree (as illustrated in "How to do a Git export"), its error message is expecting in a bare repo which, by definition, has no working directory.