Skip to content

Instantly share code, notes, and snippets.

@kohashi
Last active January 8, 2016 04:34
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 kohashi/c33ca2815bbc5edeac82 to your computer and use it in GitHub Desktop.
Save kohashi/c33ca2815bbc5edeac82 to your computer and use it in GitHub Desktop.
Git: Submodule地獄からの脱出 ref: http://qiita.com/kohashi/items/f4a50c5436b326e9475b
git rm --cached testSubModule
git rm .gitmodules
git checkout -b __work_for_import__
cd ..
git remote add importSubmodule testSubModule/
git pull importSubmodule __work_for_import__
git filter-branch --subdirectory-filter testSubModule/ HEAD
git push importSubmodule __work_for_import__
git reset --hard HEAD^
rm -rf testSubModule/.git
git add testSubModule
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
# deleted: .gitmodules
# deleted: testSubModule
# new file: testSubModule/README.md
# new file: testSubModule/...submoduleのファイルがたくさん...
# new file: testSubModule/...
# new file: testSubModule/...
# new file: testSubModule/...
git rm -r --cached testSubModule
cd testSubModule
git init
git add .
git commit -m "change to submodule"
git remote add origin リモートリポジトリのパス(git@github.com:Xxx/testSubModule.git等)
git pull origin master
git checkout --ours .
git commit -a
git push origin master
git filter-branch --index-filter \
'git ls-files -s | sed "s@[[:cntrl:]]\"*@&testSubModule/@" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE || true' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment