I want to keep expanded javascript files in my repos to create a history of modifications, but deploying just minified files (ended with .min.js). Theres a way to ignore everything that ends with .src.js just when deploying, keeping these files commited?
My post-receive:
#!/bin/sh
GIT_WORK_TREE=/var/www/html/mywebsite/ git checkout -f
In case git has no way to do that, I thought about adding some rm command into post-receive to delete files after “git checkout -f”. Something like that
GIT_WORK_TREE blah blah blah ... git checkout -f && find /var/www/html/mywebsite/assets/js/ -type f -name "*.src.js" -exec rm -f {} \;
I typically use rsync for things like this so that the .git directory isn’t included in what gets deployed. You can use –exclude=PATTERN to ignore the .src.js files.
rsync –delete -l -r –exclude=”.git” –exclude=”*.min.js” –exclude=”tmp” sourceDir destDir
sourceDir or destDir can be ssh hosts as well. I would suggest putting this in a script that you run manually instead of a git hook so you can control when changes go live. (I typically run scripts like this with Jenkins.)