Clearing Submodules in Git
I have a site that I inherited and at first, I just set up git repos in the subfolders I was working on, however, as time went on it seemed to be a better idea to have the entire site be one large repo. I didn’t formally set up submodules, but when I would run git status on the top level repository, it looked like this:
# modified: www/reports/compliance/cds (modified content, untracked content)
# modified: www/reports/pic2 (modified content)
# modified: www/reports/standard/degree/time2deg (modified content)
# modified: www/reports/standard/enrollment/dailyEnrollment/report.php
# modified: www/reports/standard/factbook (new commits, modified content, untracked content)
# modified: www/reports/standard/financial (modified content)
I wanted to keep the history from the sub-repos and this link was a major help, but I didn’t do exactly what they said, so I thought I’d document it here.
- git remote add submodule_origin path/to/sub/repo
- git fetch submodule_origin
- git merge -s ours –no-commit submodule_origin/master
- git rm –cached path/to/sub/repo
- rm -rf path/to/sub/repo/.git
- git add path/to/sub/repo
- git commit -m “removed submodule”
- git remove rm submodule_origin