Why GIT reports “fatal: This operation must be run in a work tree” when exporting from bare repo?

纵然是瞬间 提交于 2019-12-22 09:56:34

问题


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.


回答1:


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.)




回答2:


As mentioned in "backing up project which uses git", git bundle would be more appropriate.

git archive just creates tarballs of trees (snapshots) but doesn't preserve commits and history.

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.



来源:https://stackoverflow.com/questions/2996301/why-git-reports-fatal-this-operation-must-be-run-in-a-work-tree-when-exportin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!