I have a repository with a detached worktree. Normally if I need to work on the repo, I can change the config file as follows and use commands like git status and git checkout:
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /var/www/mysite.net/httpd/
# TO PUSH REPO TO STAGE: change bare=false and uncomment the worktree
Now though, I'm getting the error fatal: This operation must be run in a work tree. I've got a bunch of sites set up this way so I'm sure I have just forgotten something, but I can't figure out what. Can anyone think of what would cause this?
Dumb mistake. That worktree should have been to a .com instead of a .net.
So I guess my answer is the usual one - double check your spelling.
Usually I use the git level options to get git to work like this:
git --work-tree=some/dir --git-dir=some/other/dir push
or, you can set the environment variables that have the same effect. In past versions of git, the effective active paths defined like this worked for some commands while not others.
Currently I'm using the git level options as they seem to work for all commands.
One more thing, if you override the work-tree, you need to also specify the git folder. Ie, you can't specify one without the other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With