Skip to content

Instantly share code, notes, and snippets.

@frimik
Created March 9, 2013 19:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frimik/5125436 to your computer and use it in GitHub Desktop.
Save frimik/5125436 to your computer and use it in GitHub Desktop.
Make damn sure that git submodule sync is going to work.
#! /usr/bin/env ruby
submods = Hash.new
%x{git config -f .gitmodules --get-regexp '^submodule\..*\.(path|url)$'}.lines.each do |l|
submodule, key, value = l.match(/^submodule\.(.*)\.(path|url)\s+(.*)$/)[1..3]
submods[submodule] = Hash.new unless submods[submodule].is_a?(Hash)
submods[submodule][key] = value
end
submods.each_pair do |s,k|
%x{git submodule add #{k['url']} #{k['path']}}
end
%x{git submodule sync}
@diegodorado
Copy link

good trick!

@kdojeteri
Copy link

Thank you for this. I found myself trying to add over 20 submodules to a repo and doing it one by one would've been a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment