Pushing to a remote git working copy

by jenny on 13 January 2010 - 09:31pm in

In the case where the remote working copy is the document root of your site and no one is ever making changes there, it's extremely annoying that git provides no flag to the push command to allow you to update the work tree as opposed to only the index.

Enter the post-update hook.

  • download the post-update hook
  • in the remote working copy (which you don't intend to actually work in), place the post-update file in $working_copy/.git/hooks
  • make it executable

Voila. The working copy now actually updates when you push to it.

You will probably also want to suppress the long warning message that spews out every time you do this.

On the remote working copy:

$ git config receive.denyCurrentBranch ignore


Advanced note: if you'd like to automatically pop stashed remote working copy changes back onto HEAD, see the attached stash-pop.patch to the post-update hook. Use at your own risk. ;)

stash-pop.patch472 bytes
post-update.orig2 KB
post-update.patched2.21 KB