I'm implementing GIT for web developemnt, and I want to have the working copy repository that everybody pushes to automatically reflect the latest commit in it (since it is online for everyone on the team to see as a testing site). Right now, you have to run "git reset --hard HEAD" on the repository after somebody pushes to it in order to be up to date.
+1
A:
For one, you generally don't push to a non-bare repository, precisely because you can end up too easily with an incoherent state between the working directory and the index.
warning: updating the currently checked out branch; this may cause confusion,
as the index and working tree do not reflect changes that are now in HEAD.
But since in your case, you want to take advantage of an existing "live" repo, you could setup a post-receive hook.
#!/bin/sh
export GIT_DIR=
cd ..
echo "Resetting working tree..."
git reset --hard
echo "Finished resetting working tree."
, as suggested by Frerich Raabe in "Git: Post-update hook that runs a script that needs access to all files in the repository"
VonC
2010-06-03 20:20:54