Skip to content

Instantly share code, notes, and snippets.

@bblanchon
Created December 29, 2014 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bblanchon/56880f07c42a957d11a6 to your computer and use it in GitHub Desktop.
Save bblanchon/56880f07c42a957d11a6 to your computer and use it in GitHub Desktop.
Git: converts a submodule to a subtree
#!/bin/bash
# Converts a submodule to a subtree
PREFIX=$1
set -euv
mkdir -p "/tmp/$PREFIX"
cp -R "$PREFIX" "/tmp/$PREFIX"
git rm $PREFIX
git commit -m "Remove submodule $PREFIX"
mv "/tmp/$PREFIX" "$PREFIX"
rm "$PREFIX/.git"
git add "$PREFIX"
git commit -m "Restore subtree $PREFIX"
git log -n 2
git status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment