Created
March 28, 2012 19:53
-
-
Save philcali/2229955 to your computer and use it in GitHub Desktop.
Safely removes submodules from a git repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo Removing .git directories in the submodules | |
cat .git/config | grep submodule | sed 's/\[submodule \"\(.*\)"\]/\1/' | xargs find | grep "./.git$" | xargs rm -r | |
echo Removing .git cached | |
cat .git/config | grep submodule | sed 's/\[submodule \"\(.*\)"\]/\1/' | xargs git rm --cached | |
echo Remove submodule entries from .gitmodules | |
git rm .gitmodules | |
echo Remove submodule entries from .get/config | |
cat .git/config | sed ':a;N;$!ba;s/\[submodule .*\]\s*//' | sed 's/^url.*//' > .git/config | |
# Comment out everything below if you want to verify changes | |
echo Adding changes | |
git commit -m 'Remove submodules' | |
# Comment out below code to NOT commit the submodule code to base repo | |
echo Adding previous Modules as repository code | |
git add . | |
git rm --cached rm_gitmodules | |
git commit -m 'Added module code' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome. I just copy the updated code over the second repo, ignoring the .git related files.
My exclude file is as follows: