Skip to content

Instantly share code, notes, and snippets.

@moyaldror
Last active August 3, 2021 04:51
Show Gist options
  • Save moyaldror/63b4c2b601592aa3ae8a317adec00a1c to your computer and use it in GitHub Desktop.
Save moyaldror/63b4c2b601592aa3ae8a317adec00a1c to your computer and use it in GitHub Desktop.

Revisions

  1. Dror Moyal renamed this gist Feb 14, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Dror Moyal created this gist Feb 14, 2019.
    18 changes: 18 additions & 0 deletions .sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    if [ $# -ne 1 ]; then
    echo "Usage: $0 <submodule full name>"
    exit 1
    fi

    MODULE_NAME=$1
    MODULE_NAME_FOR_SED=$(echo $MODULE_NAME | sed -e 's/\//\\\//g')

    cat .gitmodules | sed -ne "/^\[submodule \"$MODULE_NAME_FOR_SED\"/,/^\[submodule/!p" > .gitmodules.tmp
    mv .gitmodules.tmp .gitmodules
    git add .gitmodules
    cat .git/config | sed -ne "/^\[submodule \"$MODULE_NAME_FOR_SED\"/,/^\[submodule/!p" > .git/config.tmp
    mv .git/config.tmp .git/config
    git rm --cached $MODULE_NAME
    rm -rf .git/modules/$MODULE_NAME
    rm -rf $MODULE_NAME