Last active
February 11, 2021 22:08
-
-
Save niartenyaw/083fc6ac6d7779989acd4078a5efbced to your computer and use it in GitHub Desktop.
App Academy - Remove unwanted submodule from nested Git repos and re-add all the files inside of it
This file contains 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
# In most cases, a single Rails app will be attached to a single repo | |
# As of Rails 5.1, initializing a new project will also automatically initialize Git | |
# This is perfect in most circumstances, but at App Academy, students have homework and | |
# project repos that contain multiple rails apps inside them | |
# To account for this without pushing the submodules, students need to remove the .git | |
# directory before adding and commiting the new project, but most do not, resulting in | |
# unwanted submodules and missing work in the repo | |
# This gist is intended to walk through how to remove the submodule and re-add the missing | |
# files inside that directory | |
# NOTE: | |
# ONLY do this if you do not care about tracking previous commits associated with the | |
# submodule repo | |
# Navigate to the directory above the submodule | |
cd path/to/dir | |
# Tell git to remove the submodule from its tracking | |
git rm -r --cached sub_module_folder | |
# Check to see that the submodule folder is untracked | |
git status | |
# Remove the submodule's .git | |
# MAKE SURE TO INCLUDE THE TRAILING /.git | |
rm -rf sub_module_folder/.git | |
# Now add the folder | |
git add sub_module_folder | |
# Check that all the files have been added | |
git status | |
# Commit the submodule's folder and push! | |
git commit -m "Fix submodule" | |
git push origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment