In order to update my website remotely with git, I have created a bare git repo at the root of my shared hosting account together with the following post-receive hook:
#!/bin/sh
export GIT_WORK_TREE=/public_html
git checkout -f
This initially worked as intended: when pushing my changes to the remote repo, the post-receive hook fired and files were checked out to the /public_html folder.
However, I am now getting a "fatal: This operation must be run in a work tree" error on checkout. I have no clue why this error is appearing now, since I haven't made any change to my setup.
I am stuck. To me this should just work (and it actually did), unless I have completely misunderstood how git works. I have been looking for questions similar to mine but haven't found anything useful so far.
I would be grateful for any idea where I should look.