Since github doesn’t execute (the safe option for jekyll) plugins, I am trying to develop a small and clean way to deploy the compiled files to the branch master.
The usual source is in the branch boilerplate, from there I run jekyll and generate the code, everything works.
In the master branch I only have the following Makefile
default:
git checkout boilerplate
git subtree split -P _site -b site
git checkout master
git merge -X theirs site
git branch -D site
and the file .nojekyll (I’m using the subtree command from here)
However this does not work. It generates the site branch with all the code, but when I merge into master, all it says is:
Already up-to-date.
How to fix this?
What I want to accomplish is to overwrite any existing files in master BUT not delete the files which don’t exist in branch site (like the aforementioned Makefile and .nojekyll, which is important to be kept there).
Note: I want to do it from scratch in order to maintain control over the deployment process. I don’t want to 1. introduce new dependencies 2. use other tools.
As I told on IRC I’d go with a git hook (
git help hooks)I hacked
thisscript real quick.Place it under
$GIT_DIR/.git/hooks/.I tested it as a post-commit hook commiting from
$_origbranchand checked the results on the other branch ($_destbranch).It should kind-of do what you want. Worked fine, so I hope it fits you or steers this into somewhat right direction.
have fun o/
Just an update to say this works with bash and Linux.
It can probably be written in POSIX sh too.
Also, I believe mktemp is GNU-coreutils only, so other systems may need to replace this.
NOTE: this only runs when you commit in the branch specified by
$_origbranch. You can ofcourse change that. I believe it’s simple enough for anyone to do that.