Skip to content

Instantly share code, notes, and snippets.

@Abizern
Created January 14, 2014 15:23
Show Gist options
  • Select an option

  • Save Abizern/8420005 to your computer and use it in GitHub Desktop.

Select an option

Save Abizern/8420005 to your computer and use it in GitHub Desktop.
Recurse the current directory and run git gc on all non-bare repositories.
#!/usr/bin/env ruby
# A simple script that recurses through the current directory and runs
# git garbage collection on non-bare repositories
Dir.glob("**/.git") do |dir|
working_dir = File.dirname dir
puts "#{working_dir} being garbage collected."
`cd #{File.expand_path working_dir};git gc --aggressive --prune --quiet`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment