19

I have a subproject in a Git repo that I want to remove but am not able to. On the GitHub web interface the submodules are shown with black (or grey) folder icons and are not clickable.

submodule in git repo

There are some issues with that folder that even if my local code has files in that folder and I push to my repository, changes are not applied on the GitHub remote. Somehow this folder is ignored. I checked that it is not in .gitignore file.

On trying to remove the subproject I used:

git submodule deinit submodule-name

but it gives error that

error: pathspec 'submodule-name' did not match any file(s) known to git. Did you forget to 'git add'?

What's the issue here?

6
  • 1
    Try removing the submodule this way
    – halex
    Jan 27, 2014 at 13:04
  • 1
    for reference: the github icons could be found here: github.com/styleguide/css/7.0 The blue ones are used with class .octicon-file-directory the grey one is .octicon-file-submodule, so I also guess that it's something submodule related.
    – eckes
    Jan 27, 2014 at 13:07
  • @random At first I did not even know that the folder with different icon is submodule. I am completely new to this.
    – Geek
    Jan 28, 2014 at 4:48
  • Your question says you found out it was a submodule, and your answer says the question is a duplicate as well
    – random
    Jan 28, 2014 at 4:50
  • @random It was a doubt that it is submodule and with that doubt I tried a command (mentioned in question). That did not work and thus I thought it might be a submodule and it might not be. Second thing my question did not say that it was submodule, you edited it to sound like that. Please review my old question by considering my arguments that I was not sure that it was a submodule.
    – Geek
    Jan 28, 2014 at 4:55

2 Answers 2

37

If the git submodule deinit fails (maybe because the .gitmodules doesn't list that submodule), try to remove at least the special entry in the index:

git rm --cached submodule-name
git commit -m "Remove submodule entry"
git push

The gray folder should then be gone on GitHub side.

4
  • 1
    fatal: pathspec 'submodule-name' did not match any files
    – user4964330
    May 31, 2016 at 11:52
  • @frageDE Please ask a new question, with all relevant details (OS version, git version, ...)
    – VonC
    May 31, 2016 at 12:48
  • git push will not work because it will expect some origin. How can I make it work? 21 hours ago
  • @HarshSharma Specify origin on the first push: git push -u origin myBranch. See "Why do I need to explicitly push a new branch?".
    – VonC
    20 hours ago
6

This worked https://stackoverflow.com/a/1789374/1798394 :

git rm --cached path/to/submodule
rm -rf path/to/submodule
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.