Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix broken submodule config in git?

I'm hitting this git error with sub module creation. I initial had a bad URL in the command, now any additional runs show this error. Any ideas on what is wrong?

$ git submodule add -f https://github.com/Shougo/vimproc.vim.git .vim/bundle/vimproc
Adding existing repo at '.vim/bundle/vimproc' to the index
fatal: Not a git repository: .vim/bundle/vimproc/../../../.git/modules/.vim/bundle/vimproc
Failed to add submodule '.vim/bundle/vimproc'
like image 982
cmcginty Avatar asked Oct 22 '13 04:10

cmcginty


People also ask

How do you fix a dirty 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 .

How do I manage git submodules?

Use the git submodule update command to set the submodules to the commit specified by the main repository. This means that if you pull in new changes into the submodules, you need to create a new commit in your main repository in order to track the updates of the nested submodules.

Can I modify the submodule in git?

If you want to make a change within a submodule, you should first check out a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit.


1 Answers

Maybe the submodules were added to the index. You should remove them from the index.

To remove a submodule completely, perform following steps:

1 remove these lines from .git/config

[submodule ".vim/bundle/vimproc"]
    url = https://github.com/Shougo/vimproc.vim.git

2 remove these lines from .gitmodules

[submodule ".vim/bundle/vimproc"]
    path = .vim/bundle/vimproc
    url = https://github.com/Shougo/vimproc.vim.git

3 remove the submodule directory

rm -rf .vim/bundle/vimproc

4 unstage submodule

git rm --cached .vim/bundle/vimproc

5 remove submodule directory in .git/modules

rm -rf .git/modules/.vim/bundle/vimproc

Finally, add the submodule again.

like image 108
ton Avatar answered Oct 03 '22 07:10

ton