Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Don't touch git files on #cleanup #337

wants to merge 1 commit into from

In my usecase I built site on local machine and push it to github repository.
Probably every person that uses modified version of jekyll would do this in order to have flexibility to change source and use github for hosting.

So jekyll should not remove .git repository during Site#proccess.

@bogdan bogdan Site#clean: Make .git directory stay
When site content destination is a git repository
It is a good idea to skip the .git directory

+1 - This would be great - however there's a bug in this commit, it can't have $ at the end, or it still deletes all files in .git

An even better solution would be to have the exclude list as a configuration variable so anyone can add what they want, and default config can include a commented out list of .svn, .git, etc., etc.



As plugins are disabled for Github Pages, the target folder will most likely have a .git folder that has to stay. @MikeSchroll idea of having configurable excludes seems reasonable.








+1. We're building out a site that would be best if we can keep a .git repository in _site. It'd be awesome if that weren't deleted upon build.


Check out my pull request: #556. I think you'll find that this is suitable. Thoughts, @MikeSchroll and @bogdan?


I like @MikeSchroll 's idea to have configuration option to exclude some files from cleanup process and make it default to .git .svn etc.


@parkr Looks great!
Agree with @bogdan that we might as well store the list of extensions as a configurable variable, pre-populated with the most common appropriate .dotfiles


Great! I'll rework it very soon. Thanks!

@parkr parkr referenced this pull request

Added cleanup config #540


Why are people creating a repo inside of _site when you can just version control the source of the static site?


Because when generate _site locally you can change jekyll runtime. E.g. overwrite methods, write custom ruby code, use jekyll from your own fork.


I've created a pull request based on parkr's one #556: #630
It adds a configuration variable: keep_files which defaults to ['.git'].


Whaddaya think, @bogdan? Also, @tombell, my answer to your question: antiquated production servers used @ Cornell serve just the raw stuff (do not serve using WEBrick/Thin which would just serve the "compiled" files) so we have to version control just the output and rsync it with the server.

@bogdan bogdan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 22, 2011
  1. @bogdan

    Site#clean: Make .git directory stay

    bogdan authored
    When site content destination is a git repository
    It is a good idea to skip the .git directory
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +1 −1  lib/jekyll/site.rb
  2. +3 −0  test/test_site.rb
2  lib/jekyll/site.rb
@@ -210,7 +210,7 @@ def cleanup
# all files and directories in destination, including hidden ones
dest_files =
Dir.glob(File.join(self.dest, "**", "*"), File::FNM_DOTMATCH) do |file|
- dest_files << file unless file =~ /\/\.{1,2}$/
+ dest_files << file unless file =~ /\/\.{1,2}$/ || file =~/\/\.git$/
# files to be written
3  test/test_site.rb
@@ -146,6 +146,7 @@ class TestSite < Test::Unit::TestCase'qux/obsolete.html'), 'w')
# empty directory
+ FileUtils.mkdir(dest_dir('.git'))
teardown do
@@ -153,6 +154,7 @@ class TestSite < Test::Unit::TestCase
+ FileUtils.rm_rf(dest_dir('.git'))
should 'remove orphaned files in destination' do
@@ -161,6 +163,7 @@ class TestSite < Test::Unit::TestCase
assert !File.exist?(dest_dir('obsolete.html'))
assert !File.exist?(dest_dir('qux'))
assert !File.exist?(dest_dir('quux'))
+ assert File.exist?(dest_dir('.git'))
Something went wrong with that request. Please try again.