Every time I run Jekyll it destroys the entire contents of the destination folder. The problem with this is that my destination directory is a small git repo from which I use to push to my actual server. Is there a way to stop Jekyll deleting the Git files so that I don't have to generate the contents then copy them over?
You could have:
GIT_WORK_TREE
variable with the destination folder as valueIn other words, a .git
don't have to be necessary in the working tree directory itself.
It can be elsewhere, and your script can refer to the actual working tree through GIT_WORK_TREE
or through a --work-tree=<path>
option.
If your script is part of the destination directory where Jenkyll copies/erases files, you can do the opposite, and mention where the .git
actually is with GIT_DIR
variable or with --git-dir=<path>
option.
To have new --work-dir
as default options to your repo, you can use git-config --add core.worktree ../PATH/
, where PATH
- path to actual working directory relative to .git
.
Have you had a look at the Deployment section of the Jekyll wiki? - https://github.com/mojombo/jekyll/wiki/Deployment. It clearly explains Jekyll deployment steps.
And why are you pushing from the destination? That is bad! Push it from some other clone.
I also want this setup. Found this pull request to fix Jekyll, making it not delete the .git dir: https://github.com/mojombo/jekyll/pull/337
Read my comment there, as:
Anyway, my Jekyll line now reads: dest_files << file unless file =~ /\/\.{1,2}$/ || file =~/\/\.git/
Works great! I'm even using octopress (just change your deploy_dir to be public) and comment out the following lines in Rakefile:
# (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
# Rake::Task[:copydot].invoke(public_dir, deploy_dir)
# puts "\n## copying #{public_dir} to #{deploy_dir}"
# cp_r "#{public_dir}/.", deploy_dir
Now your public dir (instead of _deploy dir) can be your github repo to publish your site (submodule of a branch or my parent repo in my case)
Seems senseless to have public and _deploy with octopress, but I'm happy to hear other reasons why to split public and _deploy dirs - besides Jekyll deleting the .git dir. (I read through the full commit history of octopress, but couldn't find any explanation for why its done this way)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With