I've used this 'tutorial' to set up a DSP environment: http://toroid.org/ams/git-website-howto (Yes, I don't have a T).
My workflow is very easy:
- Develop locally (D)
- Commit a few things
- Commit more things
- Push to Staging (and Github) (S)
- Test new code on Staging
- Push to Production (P)
My code contains CSS files that are minified by my code and then saved to 1 file: all.css
. Locally, I've turned that option off, so I don't have to manually remove all.css
all the time every time I change my CSS. On both Staging and Production, they should cache as soon as possible (so create all.css
from the separate CSS files).
The problem is every time I push, I have to remove all.css
(and all.js
-- same exact story) to see the changes (and properly test).
From the tutorial I made a post-receive
hook that checks out the changes into a certain folder (where Apache reads the code).
My current post-receive
hook:
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
I want to reuse $GIT_WORK_TREE
to remove two files within $GIT_WORK_TREE
(being www/all.css
and www/all.js
), but I can't... There's no var $GIT_WORK_TREE on the next line.
So I changed it to this, but I don't like that, especially if I want to do more with it in the future:
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
rm /var/www/www.example.org/www/all.css
rm /var/www/www.example.org/www/all.js
$GIT_WORK_TREE
is NOT reused like this.
Things I've tried that don't work:
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
rm $GIT_WORK_TREE/www/all.css
rm $GIT_WORK_TREE/www/all.js
rm: file doesn't exist etc (/www/all.css) ($GIT_WORK_TREE
is empty)
GIT_WORK_TREE=/var/www/www.example.org
git checkout -f
fatal: this operation must be run in a work tree
GIT_WORK_TREE=/var/www/www.example.org
cd $GIT_WORK_TREE
git checkout -f
fatal: Not in a git repository (or any .....)
I guess my problem is as much with how Bash works as it is with how GIT works =)
See Question&Answers more detail:
os