Created
January 7, 2014 16:52
-
-
Save TopherGopher/8302357 to your computer and use it in GitHub Desktop.
Ever had a submodule that you wanted to keep the full history of, but you no longer wanted it is a submodule? You want it as part of the main project.
This set of commands allows you to do just that - pulling the submodule's history and incorporating it into the main project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Just in case something goes wrong, let's do this un-submodulifying on a new branch. | |
git checkout new_branch | |
# You need to go in and remove the SUBMODULE_DIR project from your .gitmodules file | |
# Save the URL that the submodule points to. | |
vim .gitmodules | |
# We're going to completely wipe out the SUBMODULE_DIR from your project...trust me... | |
git rm --cached SUBMODULE_DIR | |
git commit -am "Removed SUBMODULE_DIR as submodule" | |
rm -rf SUBMODULE_DIR | |
# Now we're going to add that SUBMODULE_DIR as a remote. You can get this URL from | |
# what you removed when you edited the .gitmodules file. | |
git remote add -f TEMP_REMOTE [email protected]:Caveat4U/submodule_project.git | |
# Basically? Merge the history together from the submodule and this project. | |
git merge -s ours --no-commit TEMP_REMOTE/master | |
git read-tree --prefix=SUBMODULE_DIR -u TEMP_REMOTE/master | |
# FINALLY, commit all these new changes | |
git commit -am "SUBMODULE_DIR is now part of main project" | |
# Now when you're done with all that, push to your new_branch, and create a pull request from new_branch -> master and everything will be green to go. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment