DarthSpeedious
DarthSpeedious

Reputation: 1007

How to restore Git submodule after deleting it?

I accidentally deleted a submodule directory/repository. After doing git submodule init i tried running git submodule update which gives me the following error:

fatal: Not a git repository: ../../.git/modules/externals/foo

Unable to find current revision in submodule path 'externals/foo'

Can somebody please tell me what i am doing wrong?

EDIT: I deleted the submodule directory, I can clone the submodule repository for which the link is in .gitmodules, but I read somewhere that i can completely delete submodules by deleting the .git/modules/externals folder which i deleted (I dont know if this was right thing to do) anyway i downloaded the repository and pasted on the location where the submodule is supposed to exist but that is now the correct way. git submodule gives the following output:

+244d6addc83d1cc801ff1880f71574d3fcc6b77e externals/foo (heads/master)

Upvotes: 7

Views: 5143

Answers (1)

fgiraldeau
fgiraldeau

Reputation: 2734

I recovered my working copy using comment made by @UweGeuder:

git submodule deinit -f .
git submodule update --init

Upvotes: 7

Related Questions