On our server we have, for each project, 2 folders: /repository and /htdocs. Htdocs being a clone of repository, which is the bare repo. Every developer has his own repository clone to work in. htdocs is there to preview the project to project managers.
I would like to set up a post-receive hook that automatically updates htdocs when updates are pushed from the developers.
I have following in my post-receive hook:
#!/bin/sh
GIT_WORK_TREE=../htdocs git pull origin master
However, when I push, I see following error: 
Can anyone tell me what’s going wrong?
Note that
#!/bin/sh
GIT_WORK_TREE=../htdocs git checkout -f
works, but this is kinda slow (as the project is pretty big). It is also possible someone made some bugfixes in htdocs that would get lost with checkout -f if they weren’t committed.
This should work:
If you don’t specify GIT_DIR, git believe the repo is still “
repository” (the bare repo), which might not have a remote named “origin” (hence the error message).