Skip to content

Instantly share code, notes, and snippets.

@fmasuhr
Created February 29, 2016 16:31
Show Gist options
  • Save fmasuhr/6fbea3cea32e62ba74db to your computer and use it in GitHub Desktop.
Save fmasuhr/6fbea3cea32e62ba74db to your computer and use it in GitHub Desktop.
Update all git repositories in a specified path
require 'git'
root_path = ARGV[0]
raise 'Specify root path as first parameter e.g. \'/Users/myname\'' unless root_path
# Find all folders wich are git repositories
Dir[File.join(root_path, '*/.git')].each do |git_path|
path = git_path.gsub('.git', '')
git = Git.open(path)
git.fetch
git.pull
puts "Updated #{path}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment