Skip to content

Instantly share code, notes, and snippets.

@mcascardi
Created September 29, 2020 00:49
Show Gist options
  • Select an option

  • Save mcascardi/f01ad7eeec25f08c1b1ebc7100a5e16c to your computer and use it in GitHub Desktop.

Select an option

Save mcascardi/f01ad7eeec25f08c1b1ebc7100a5e16c to your computer and use it in GitHub Desktop.
Process for removing a git submodule and merging the history back into the parent repo
#!/bin/bash
# Gratitude: https://stackoverflow.com/questions/1759587/how-to-un-submodule-a-git-submodule
origin=submodule_origin
url=git://url/to/submodule/origin
path=submodule_path
echo "git remote add $origin $url"
echo "git fetch $origin"
echo "git merge -s ours --no-commit --allow-unrelated-histories $origin/master"
echo "git rm --cached $path"
echo "-- GO AHEAD REMOVE FROM THE SUBMODULE FILE --"
echo "git add .gitmodules"
echo "rm -rf $path/.git"
echo "git add $path"
echo "git commit"
echo "git push"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment