Pushing a Git source tree, not just a repository

git

Solution

I usually create a non-bare repository with a file .git/hooks/post-receive containing

#!/bin/sh
cd ..
env -i git reset --hard

This file must be executable and a branch must be checked out.

Then every time you push to that repository, the work tree will be reset to the latest version of the current branch. Any local change will be overwritten (but untracked files won't be removed).

Git now displays a warning when you push to a checked out branch (and will reject it in future releases). To avoid this you can set this config on the remote repository :

git config receive.denyCurrentBranch ignore

You can work on this repository, but you must commit your changes before any push is done to it.

I found the tip there : http://debuggable.com/posts/git-tip-auto-update-working-tree-via-post-receive-hook:49551efe-6414-4e86-aec6-544f4834cda3

Problem

I'm using Git wrong. I want to use it right. Here's what I've got: Over here, on my development machine is a Git repository, that I commit to and test on. Over there, is my web-server - the one place this code will be deployed. The web-server has another bare git repository that I can push to, over SSH, when I am ready to deploy. What I want to happen is to have a view into the Git repository which always has the latest versions of the source files (on some branch or with some tag). What I COULD do is to create another (non-bare) git repository on the web-server, and do a manual pull after each push, but I was hoping to avoid having to log in to the web-server each time I do a git push. Is there a way to do a remotely "push to the web-server and refresh its checked-out files, if I promise I didn't edit any files on the web-server"? Or am I just doing it so wrong you want to slap me? :-)

Original source