fatal:此操作必须在工作树中运行

发布于 2025-01-05 01:52:57 字数 556 浏览 1 评论 0原文

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

也许我会在命令后给出命令的一些信息

/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲸落 2025-01-12 01:52:57

您的存储库是裸露的,即它没有附加工作树。您可以在本地克隆它来为其创建工作树,或者您可以使用其他几个选项之一来告诉 Git 工作树在哪里,例如单个命令的 --work-tree 选项,或 GIT_WORK_TREE 环境变量。还有 core.worktree 配置选项,但它不能在裸存储库中工作(检查手册页了解它的作用)。

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文