Created
February 29, 2016 16:31
-
-
Save fmasuhr/6fbea3cea32e62ba74db to your computer and use it in GitHub Desktop.
Update all git repositories in a specified path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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