Skip to content

Instantly share code, notes, and snippets.

@frimik
Created March 9, 2013 19:32
Show Gist options
  • Select an option

  • Save frimik/5125436 to your computer and use it in GitHub Desktop.

Select an option

Save frimik/5125436 to your computer and use it in GitHub Desktop.

Revisions

  1. frimik created this gist Mar 9, 2013.
    15 changes: 15 additions & 0 deletions git-submodule-sync.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #! /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}