I have a central, bare, git repository which all of our developers push to. This is our origin. I use origin to push to a separate, non-bare, repository and overwrite all changes. This is intended to be a demonstration area, so we can immediately see changes when somebody pushes to a specific branch.
Origin will push to the demo repository, but the working files are not changed. I have a post-receive hook on origin that calls:
git push -f ssh://git@<host>/<path> <branch name>
Then my post-receive hook on the demo repo calls:
git fetch origin <branch name>
git reset --hard FETCH_HEAD
If I call those commands on the demo box, my working copy updates fine. But calling them from the post-receive (on the demo repo) leaves changes which need to be manually committed. I want to skip the step where I manually update the working copy.
I realize, through some google-fu and stackoverflow searching, that it's generally bad practice to push to a non-bare repository. I understand the risks, but I'd like this to work, since we use a bare repository for our origin.
Does git do some kind of extra check to prevent the working copy from being updated by the post-receive? Is there any workaround?