Skip to content

Instantly share code, notes, and snippets.

@brucem
Created October 2, 2013 04:53
Show Gist options
  • Save brucem/6789282 to your computer and use it in GitHub Desktop.
Save brucem/6789282 to your computer and use it in GitHub Desktop.
Capistrano recipe to clear the cached repo copy. Handy if you change repos. You'll see a "fatal: Could not parse object" error if you do change git repos and don't clear the cache
desc "Clear cached copy"
task :clear_cached_copy do
cached_copy_path = "#{shared_path}/cached-copy"
cached_copy_exists = capture("if [ -d '#{cached_copy_path}' ]; then echo '1'; fi")
if cached_copy_exists.to_i == 1
puts "Removing cached copy"
run "rm -fR #{cached_copy_path}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment