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?

Merc
  • 789
  • 1
  • 6
  • 16

1 Answers1

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".

Mort
  • 166
  • 1
  • 5
  • 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 01:24
  • From [Git-Internals-Environment-Variables](https://git-scm.com/book/en/v2/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