Skip to content

Instantly share code, notes, and snippets.

@PeloNZ
Forked from frimik/git-submodule-sync.rb
Created January 19, 2016 11:18
Show Gist options
  • Save PeloNZ/669969ce1e83d913c9ae to your computer and use it in GitHub Desktop.
Save PeloNZ/669969ce1e83d913c9ae 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 --force #{k['url']} #{k['path']}}
end
%x{git submodule sync}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment