Search code examples
gitrepositorypushstaging

how can I create a remote git repository that accepts pushes into the working tree?


Im trying to have a shared remote repository where team members can push their changes and see them live in a staging environment.

Ive looked some options but I'm still stuck. Bare repositories have no working tree, and ive tried a normal repository with receive.denyCurrentBranch set to false, (which lets me push to the remote) but the working tree still doesnt get updated until you log into the server and do a git reset.

Ideally id like to be able to just push to the repository (one command) and see the changes updated live.


Solution

  • You will need to set up a post-receive hook on the remote repository to pull the changes to the working tree. With a bare repository, you can git-archive the HEAD and extract the archive to a directory, instead of updating a working tree.

    Reference: Git Hooks; git-archive