-
-
Save nightsparc/6d3b3c45bfc05092a10732a1495163c9 to your computer and use it in GitHub Desktop.
Complete remove of git submoule
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/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <submodule full name>" | |
exit 1 | |
fi | |
MODULE_NAME=$1 | |
MODULE_NAME_FOR_SED=$(echo $MODULE_NAME | sed -e 's/\//\\\//g') | |
cat .gitmodules | sed -ne "/^\[submodule \"$MODULE_NAME_FOR_SED\"/,/^\[submodule/!p" > .gitmodules.tmp | |
mv .gitmodules.tmp .gitmodules | |
git add .gitmodules | |
cat .git/config | sed -ne "/^\[submodule \"$MODULE_NAME_FOR_SED\"/,/^\[submodule/!p" > .git/config.tmp | |
mv .git/config.tmp .git/config | |
git rm --cached $MODULE_NAME | |
rm -rf .git/modules/$MODULE_NAME | |
rm -rf $MODULE_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment