Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use git push to update my (nginx) webserver content, while still keeping things secure. One way I could do this would be to ssh to my server, git pull from bitbucket into /srv/www, and chown -R www-data:www-data ..

It'd be slicker, though, to be able to push it there from my home computer (a la Heroku), but I'm not sure how best to handle issues of permissions and ownership.

Does anyone have advice about the most sensible way to go about this?

share|improve this question

If you were using your web server as a git server, you could go for the only slightly complicated approach of using git hooks (put your update code into a script and call that on every git update); some git hosts support hooks too, but that's going to be quite a lot more complicated as they'll be calling your update notifier over the network rather than running a local script

share|improve this answer
Very interesting, thanks! This site seems to be a very good resource for this. – Grumdrig Oct 14 '11 at 3:25


Never place any working copy inside site-tree


git archive --remote ... is your silver-bullet

share|improve this answer
up vote 0 down vote accepted

Just to close the book on this, given the extra complications that I 1) have the html for several different sites as submodules in a top-level project, and 2) want to keep the canonical source on bitbucket, I decided to just ssh in and git pull rather than having more moving parts.

(Thanks for the info in the other answers, which equipped me to learn about the different options.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.