fatal:此操作必须在工作树中运行 [英] fatal: This operation must be run in a work tree

查看:2797
本文介绍了fatal:此操作必须在工作树中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试更改分支时,我收到此错误。

I get this error when I try to change branch.

可能会提供

/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


推荐答案

您的存储库是裸的,即它没有连接到它的工作树。你可以克隆它本地为它创建一个工作树,或者你可以使用几个其他选项之一告诉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, the GIT_WORK_TREE environment variable, or the core.worktree configuration option.

这篇关于fatal:此操作必须在工作树中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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