Skip to content

Instantly share code, notes, and snippets.

@demonbane
Created July 7, 2009 17:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demonbane/142249 to your computer and use it in GitHub Desktop.
Save demonbane/142249 to your computer and use it in GitHub Desktop.
# Got a bunch of subdirectories in a project that aren't submodules, but should be?
# Here's a quick way to add them all. Just change the find command to only look in
# the directory you want.
for dir in `find vendor/extensions -type d -name .git`; do url=`cd "$dir" && git config --get remote.origin.url`; dir="${dir%/.git}"; git rm -r --cached "$dir" && git submodule add "$url" "$dir"; done
## Or, slightly more readable
for dir in `find vendor/extensions -type d -name .git`; do
url=`cd "$dir" && git config --get remote.origin.url`
dir="${dir%/.git}"
git rm -r --cached "$dir" && git submodule add "$url" "$dir"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment