cd ~/project.git
GIT_WORK_TREE=/home/ubuntu/project git checkout -f
This is the right way to checkout files from a bare repo.
But if the variable isn't see as exported by the git checkout command, you can wrap that in a script, like "unable to set GIT_WORK_TREE
variable in a bare repository when using post_update
hook" did.
That is what makes the a post-receive
work, in the directory ~/project.git/hooks/
.