fatal:此操作必须在工作树中运行
当我尝试更改分支时出现此错误。
也许我会在命令后给出命令的一些信息
/path/to/git/repo/.
:
git branch
我得到以下输出
* V1.5
V2.0
master
当我尝试该命令时
git checkout V2.0
,我得到以下输出:
fatal: This operation must be run in a work tree
配置文件内容:
cat config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = /path/to/git/repo/.git
I get this error when I try to change branch.
Probably I will give some information of the commands at
/path/to/git/repo/.
upon command:
git branch
I get following output
* V1.5
V2.0
master
And when I try the command
git checkout V2.0
I get following output:
fatal: This operation must be run in a work tree
config file contents:
cat config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = /path/to/git/repo/.git
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的存储库是裸露的,即它没有附加工作树。您可以在本地克隆它来为其创建工作树,或者您可以使用其他几个选项之一来告诉 Git 工作树在哪里,例如单个命令的
--work-tree
选项,或GIT_WORK_TREE
环境变量。还有 core.worktree 配置选项,但它不能在裸存储库中工作(检查手册页了解它的作用)。You repository is bare, i.e. it does not have a working tree attached to it. You can clone it locally to create a working tree for it, or you could use one of several other options to tell Git where the working tree is, e.g. the
--work-tree
option for single commands, or theGIT_WORK_TREE
environment variable. There is also thecore.worktree
configuration option but it will not work in a bare repository (check the man page for what it does).