Skip to content

Instantly share code, notes, and snippets.

@werdnum
Created May 7, 2015 10:08
Show Gist options
  • Save werdnum/270b8afdb540c2efd110 to your computer and use it in GitHub Desktop.
Save werdnum/270b8afdb540c2efd110 to your computer and use it in GitHub Desktop.
Simple script to fix git submodules inside subtrees
#!/bin/bash
find . -name .gitmodules | grep -v './.gitmodules' | while read file;
do
$dir = `dirname $file`
git config -f $file --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f $file --get "$url_key")
git submodule add $url $dir/$path
done
done
@werdnum
Copy link
Author

werdnum commented May 7, 2015

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