#! /bin/sh # See https://stackoverflow.com/q/1260748/7976758 if [ $# != 1 ]; then echo "Usage: $0 submodule_name" >&2 exit 1 fi cd "`git rev-parse --show-toplevel`" || exit 1 if [ \! -f .gitmodules ]; then echo "Cannot find .gitmodules. The command must be run " >&2 echo "in the top-level directory of a repository with submodules" >&2 exit 1 fi name="$1" path="$(git config -f .gitmodules --get "submodule.$name.path")" if [ -z "$path" ]; then echo "Error: submodule $name does not exist" >&2 exit 1 fi git rm "$path" && rm -rf "`git rev-parse --git-dir`"/modules/"$name" && exec git config --remove-section submodule."$name"