Created
March 24, 2012 11:54
-
-
Save doitian/2181511 to your computer and use it in GitHub Desktop.
git submodule-rm
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 | |
# refs http://stackoverflow.com/a/1260982/667158 | |
function submodule_rm() { | |
[ -z "$1" ] && return 1 | |
local path="$1" | |
local dir=$(dirname ".git/modules/$path") | |
git config -f .git/config --remove-section "submodule.$path" &> /dev/null | |
git config -f .gitmodules --remove-section "submodule.$path" &> /dev/null | |
git rm --cached "$1" | |
if [ -d ".git/modules/$path" ]; then | |
rm -rf ".git/modules/$path" | |
while rmdir "$dir" &> /dev/null; do | |
dir=$(dirname "$dir") | |
done | |
fi | |
} | |
submodule_rm "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the path is not added into index, just ignore the error message. The directory itself is not removed from disk, do it yourselves.