Skip to content

Instantly share code, notes, and snippets.

@yurikoval
Created November 12, 2013 08:27
Show Gist options
  • Select an option

  • Save yurikoval/7427470 to your computer and use it in GitHub Desktop.

Select an option

Save yurikoval/7427470 to your computer and use it in GitHub Desktop.
Fetch all remote git update for your repos in your dev folder recursively
#!/usr/bin/ruby
def is_git_repo
%x[git rev-parse 2>&1]
$?.exitstatus == 0
end
dir_to_scan = if ARGV[0]
if ARGV[0] !~ /^\//
"#{Dir.pwd}/#{ARGV[0]}"
else
ARGV[0]
end
else
Dir.pwd
end
repos = Dir.entries(dir_to_scan).select {|f| File.directory? f}
repos.each do |d|
Dir.chdir "#{dir_to_scan}/#{d}"
if is_git_repo
puts "Updating #{d}."
%x[git remote update]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment