morristech
5/29/2018 - 11:26 AM

Remove git submodule

Remove git submodule

#!/bin/bash
NAME="$1"

if [ "x$NAME" == "x" ]; then
  echo "please tell me the submodule name to remove"
  exit -1
fi

TMP_NAME = "${NAME}_tmp"

mv "$NAME" "$TMP_NAME"
git submodule deinit -f -- "$NAME"
rm -rf ".git/modules/$NAME"

git rm -f "$NAME"
git rm --cached "$NAME"
rm -rf "$TMP_NAME"