fatal: This operation must be run in a work tree [duplicate]

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

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 

回答1:

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 


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