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

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

问题描述

当我尝试更改分支时出现此错误.

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, or the GIT_WORK_TREE environment variable. There is also the core.worktree configuration option but it will not work in a bare repository (check the man page for what it does).

# git --work-tree=/path/to/work/tree checkout master
# GIT_WORK_TREE=/path/to/work/tree git status

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

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