]> git.phdru.name Git - git-scripts.git/blob - submodules/remove
Feat(submodules/remove): New way to remove
[git-scripts.git] / submodules / remove
1 #! /bin/sh
2 # See https://stackoverflow.com/q/1260748/7976758
3
4 if [ $# != 1 ]; then
5     echo "Usage: $0 submodule_name" >&2
6     exit 1
7 fi
8
9 cd `git rev-parse --show-toplevel` || exit 1
10 if [ \! -f .gitmodules ]; then
11     echo "The command must be run in the top-level directory" >&2
12     exit 1
13 fi
14
15 name="$1"
16 path="$(git config -f .gitmodules --get "submodule.$name.path")"
17
18 if [ -z "$path" ]; then
19     echo "Error: submodule $name does not exist" >&2
20     exit 1
21 fi
22
23 git rm "$path"
24 rm -rf .git/modules/"$name"
25 exec git config --remove-section submodule."$name"