tags:

views:

369

answers:

2

So, my situation is the following: I want to maintain my website using emacs-muse mode. For transferring the website (and version control), I want to use git. So I would create a hook in the remote (bare) repository that automatically copies the HTML subdir to the web directory. How can I do that from a hook? Also note that the whole directory contains a lot of files, so I can't export the whole directory.

Any help welcome.

+6  A: 
VonC
+5  A: 

You can use git archive, as it takes a path command. So, in your post-update hook you can do something like

git archive $SHA HTML | (cd dir/where/html/should/go && tar x)

this first creates a tarball of the subdir, and pipes that tarball to a tar command to untar it in the specified directory

Pieter
That sounds good, i'm gonna try that. The only question is how to get the sha hash.
jeeger
Okay, archieving HEAD works. However, archive saves "absolute" paths in relation to the git repository. However, I want to extract the files and cut the path components. How would I do that?
jeeger
try using HEAD:HTML instead "HEAD HTML"
Pieter
That is odd: your answer seems to be more specific and fits better jeeger's question, yet mine has more vote: +1 to fix that ;)
VonC