Created
December 25, 2010 12:12
-
-
Save danielctull/754845 to your computer and use it in GitHub Desktop.
An extension to git to allow easy removal of submodules
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 | |
usage() { | |
echo "usage: git dctsubmodule remove [--hard] submodulepath" | |
} | |
if [[ ! -f .gitmodules ]]; then | |
echo "git submodules not in use" | |
exit | |
fi | |
if [[ $1 != "remove" || $2 == "--help" || $2 == "" ]]; then | |
usage | |
exit | |
fi | |
submodule=$2 | |
hard=false | |
if [[ $2 == "--hard" ]]; then | |
submodule=$3 | |
hard=true | |
fi | |
submodule=$( echo $submodule | sed 's/\/$//g') | |
git rm --cached $submodule | |
git config --remove-section "submodule.$submodule" | |
git config -f .gitmodules --remove-section "submodule.$submodule" | |
if [[ $hard == true ]]; then | |
echo "rm -rf '$submodule'" | |
rm -rf $submodule | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment