Array
University of Oregon

How to remove a Git Submodule

What does a greyed-out, locked folder icon in GitHub mean? It means the subdirectory you pushed up to Github is itself a Git repo, and Github interpreted it as a submodule, which causes the locked folder behavior.

Problem: A subfolder in Github is displayed as a locked, grey folder icon.

Cause: When you pushed your local repo to Github, the subdirectory that shows up as the greyed-out folder was itself a Git repo (that you may have pushed to a PaaS like Heroku, for example). This caused Github to treat it as a submodule.

Fix: Remove the .git folder from the subdirectory.

Example

Suppose the greyed-out folder on Github is named Hello-World, and that the Hello-World directory is contained in a directory named p4.

    1. cd to Hello-World, and run this command.

      rm -Rf .git

      Note: If you have other greyed-out folders, remove the .git file from each of those directories at this time.

    2. cd to p4 and run this command to remove the greyed-out subdirectory from the p4 repo.
      git rm --cached Hello-World

      Caution! the --cached switch removes the directory from the repo without removing it from your file system. If you omit this switch, or type it incorrectly, your Hello-World directory could be deleted from your computer.

      Note: If you have other greyed-out folders, run the git rm --cached command for each of those at this time.

    3. Run these Git commands:

      git add .
      git commit -m “Remove submodule directories”
      git push origin p4-branch

      Note: You can override the remote repo on Github by using a force push command, git push -f origin p4-branch

Skip to toolbar