Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/85a5b9941e21a8419448 to your computer and use it in GitHub Desktop.
Save ziadoz/85a5b9941e21a8419448 to your computer and use it in GitHub Desktop.
Reset Mecurial and Git Repositories
#! /usr/bin/env ruby
Dir.glob("~/Projects/**").each do |dir|
next unless File.directory?(dir)
is_hg = File.directory?(File.join(dir, '.hg'))
is_git = File.directory?(File.join(dir, '.git'))
puts "Fixing " + File.basename(dir)
Dir.chdir(dir)
if is_hg
system "hg revert --all --no-backup"
system "hg pull -u"
elsif is_git
system "git reset --hard"
system "git pull"
else
puts "Skipped"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment