This question already has an answer here:
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
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).