Search code examples
gitolite

Gitolite update copy at server when push


In gitolite I've set up a new repository on the server and able to clone it from my machine. As it's a web project I need the latest working copy at /var/www/my-project, so every push made by a developer will update the files there. How can I achieve that?

thanks


Solution

  • The repos managed by gitolite are managed in ~/repositories

    You can add your own hook in ~/repositories/yourrepo.git/hooks called post-receive hook in order to checkout, on each push, the index to a working tree of your choice (like /var/www/my-project)

    See for instance "how to process files on a branch in post-receive hook in git" (which can even check for which branch is pushed).

    The checkout uses:

    git checkout --work-tree=/var/www/my-project