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)
Move into the submodule's directory, then do a git reset --hard to reset all modified files to their last committed state. Be aware that this will discard all non-committed changes.
A submodule can be located anywhere in a parent Git repository's working directory and is configured via a . gitmodules file located at the root of the parent repository. This file contains which paths are submodules and what URL should be used when cloning and fetching for that submodule.
You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .
The list of steps required to clone a Git repository with submodules is: Issue a git clone command on the parent repository. Issue a git submodule init command. Issue a git submodule update command.
I recovered my working copy using comment made by @UweGeuder:
git submodule deinit -f .
git submodule update --init
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With