I was trying to remove one sub-module from the project
Tried rm -rf .git/modules/submodulePath
After that I am having the issue
fatal: Not a git repository
For the second situation, you need to initialize the Git repository in your project folder. To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.
Fix 5 - Git - remote: Repository not found Just run the git remote update command which updates the local repo with the remote repo and its credentials. If this command is executed without any issues then your issue will be resolved.
The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.
What does “fatal: not a git repository” mean? This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right directory.
These two files contains absolute submodule path:
{submodule}/.git .git/modules/{submodule}/config
So, if you moved the repo, the absolute path in these two files are not valid, and cause the 'not a git repository' error. Just fix these files manually.
Update:
1.) Delete the relevant section from the .gitmodules file. You can use below command:
git config -f .gitmodules --remove-section "submodule.submodule_name"
2.) Stage the .gitmodules changes
git add .gitmodules
3.) Delete the relevant section from .git/config. You can use below command:
git submodule deinit -f "submodule_name"
4.) Remove the gitlink (no trailing slash):
git rm --cached path_to_submodule
5.) Cleanup the .git/modules:
rm -rf .git/modules/path_to_submodule
6.) Commit:
git commit -m "Removed submodule <name>"
7.) Delete the now untracked submodule files
rm -rf path_to_submodule
I ran into this and didn't have a .git/modules
directory in my main repository. I have one submodule 'build', so just removed any references and reinitialized it:
rm -rf .git/modules rm -rf build git submodule init git submodule update
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