1

I have a git repo on a remote server (my own). I want to make sure that after a git push onto that remote server, a new instance of the node program is pulled in the local development server (then, forever will pickup the changes and restart it).

At the moment, I have a hook doing this (post-receive):

unset GIT_DIR
export PATH=$PATH:/usr/local/bin/
cd /home/www/node/deployed/node_modules/wonder-server
git pull
echo "POST COMMIT FINISHED"

However, it comes with problems:

  • It expects modules to be installed, and in the right version, in the development machine
  • We also maintain some of the npm modules which we also update at times

Is this a good way to go about this? Or, can you think of better ways?

0

Have a look here: git as a deployment tool

There are lots more links available in a google search for "git as a deployment tool".

  • This is a fantastic link -- thank you! I really, really don't get how the first solution works: export GIT_WORK_TREE=/deploy/dir; git checkout -f master -- how does that do anything without even fetching?!? – Merc Apr 23 '16 at 1:24
  • From Git-Internals-Environment-Variables, "GIT_WORK_TREE is the location of the root of the working directory for a non-bare repository. If not specified, the parent directory of $GIT_DIR is used." So you're already in a git repo and you're just telling git to check out the working tree, but into some other place. That's pretty cool. – Mort Apr 23 '16 at 14:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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