Skip to content

Commit

Permalink
Add script to re-initialize git submodules
Browse files Browse the repository at this point in the history
This script reads .gitmodules file in a git repository and run "git
submodule add XX YY" command for each of them
  • Loading branch information
pankajlele committed Oct 15, 2012
0 parents commit 30b5d68
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addsubmodules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$gitmodules = file_get_contents('.gitmodules');
$submodules = preg_split('/\[submodule(.*)\]/', $gitmodules);
foreach ($submodules as $submoduleSpec) {
if (! empty($submoduleSpec)) {
preg_match('/path = (.*)/', $submoduleSpec, $pathMatch);
preg_match('/url = (.*)/', $submoduleSpec, $urlMatch);
$command = 'git submodule add '.$urlMatch[1].' '.$pathMatch[1];
system($command);
}
}
?>

0 comments on commit 30b5d68

Please sign in to comment.