From 25b8ae7eed1499d2450a2972ae4a0ce7664d5f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 29 Oct 2020 09:25:15 +0100 Subject: [PATCH] add script to remove submodule completely --- bin/git-submodule-remove | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 bin/git-submodule-remove diff --git a/bin/git-submodule-remove b/bin/git-submodule-remove new file mode 100755 index 0000000..4ec2237 --- /dev/null +++ b/bin/git-submodule-remove @@ -0,0 +1,17 @@ +#!/bin/bash + +SUBMODULE=$1 +git config --file=.gitmodules --remove-section submodule.${SUBMODULE} || \ + { logerror "error on removing section from .gitmodules"; exit 1; } +git commit .gitmodules -m "remove submodule $SUBMODULE from .gitconfig" +git config --remove-section submodule.${SUBMODULE} || \ + { logerror "error on removing section from .git/config"; exit 2; } +git rm --cached "${SUBMODULE}" || \ + { logerror "remove submodule from stage error"; exit 3; } +[ -d ".git/modules/${SUBMODULE}" ] && rm -rf .git/modules/"${SUBMODULE}" || \ + { logerror "error on removing submodule from unversioned .git/modules/*"; exit 4; } +git commit -m "remove submodule ${SUBMODULE}" +[ -d "${SUBMODULE}" ] && rm -rf "${SUBMODULE}" || \ + { logerror "error on removing submodule from repo"; exit 5; } +loginfo "submodule $SUBMODULE completely removed" +