33

When I run

git submodule update
No submodule mapping found in .gitmodules for path 'Classes/lib/AFKissXMLRequestOperation'

But I have no submodule Classes/lib/AFKissXMLRequestOperation in current repos

My git config is:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com:why_ios.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[submodule "External/ios-SDNestedTable"]
    url = git@github.com:why/ios-SDNestedTable.git
[submodule "External/PSStackedView"]
    url = git@github.com:why/PSStackedView.git

and .gitmodules is:

[submodule "External/ios-SDNestedTable"]
    path = External/ios-SDNestedTable
    url = git@github.com:why/ios-SDNestedTable.git
[submodule "External/PSStackedView"]
    path = External/PSStackedView
    url = git@github.com:why/PSStackedView.git
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
why
  • 23,923
  • 29
  • 97
  • 142

2 Answers2

101

check that you have the proper setting in .git/modules as well. Since a few versions ago, git adds an entry there.

Also, the tree probably has a commit object at that path. To get rid of it you can

git rm --cached Classes/lib/AFKissXMLRequestOperation

that should get rid of it once and for all.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 9
    you sir, saved me from certain insanity! – Havard Graff Nov 22 '13 at 21:13
  • I did a git rm --cached myFile but now I am unabled to do a git init on the server where it was done. I have a cluster of 4 machines and only this one is doing nothing. How to rebuild this cache? – Nicolas D Jun 30 '17 at 10:11
  • ok this was a stupid question, git reset HEAD myFile and I am good again, sorry for disturb ! – Nicolas D Jun 30 '17 at 10:13
  • 5
    UPvote this if you are from the future where the authors of git finally implement `git submodule update --init --recursive --justworkdammit` – Warren P Feb 21 '18 at 00:18
  • For some reason, mine required single quotes around the path and would not work with out it. `git rm --cached 'Classes/lib/AFKissXMLRequestOperation'` – Jason Glisson Jul 31 '19 at 18:51
3

Just leaving this here for anyone using git on Windows. It is possible to follow all of the answers online and still have it not work due to git's handling of path separators. E.g.:

My problem case was adding hugo themes via submodule:

git submodule add https://github.com/danielkvist/hugo-terrassa-theme.git themes\terrassa

will result in a .gitmodules like:

[submodule "themes\\terrassa"]
    path = themes\\terrassa
    url = https://github.com/danielkvist/hugo-terrassa-theme.git

Which will cause problems for git submodule [status || init || ...]

Manually replacing the separators to:

[submodule "themes/terrassa"]
    path = themes/terrassa
    url = https://github.com/danielkvist/hugo-terrassa-theme.git

...solved it for me.

Also solved the deployment on Netlify since they use *nix server images.

tykom
  • 659
  • 5
  • 8