Monday, April 27, 2020

Nested Git repositories can appear as phantom submodules

Tonight I helped a student who was trying to publish a project to GitHub with Android Studio but only got one subfolder in the resulting GitHub repository. git status showed that the published subfolder was a submodule with pending changes. Strangely, there was no .gitmodules file for submodule registration. There was, however, another .git directory inside that folder - it was actually a nested repository. To fix that accident, we:

  1. Deleted the subfolder's .git directory
  2. Removed the submodule from the outer repository's Git index with git rm --cached theFolder
  3. Committed the change
  4. Added the subfolder back, now as a plain directory, with git add theFolder
  5. Committed the change

No comments:

Post a Comment