I have several branches with features in my Git repo.
Every feature is some foreign repo, plugged in as a submodule.
What should I do to correct switching between branches, with and without submodules?
Example:
$ git init
$ git commit -m "empty" --allow-empty
$ git checkout -b feature
$ git submodule init
$ git submodule add git://feature.git feature
$ git commit -a -m "add feature"
$ git checkout master
warning: unable to rmdir feature: Directory is not empty
And we have a feature in our master
branch work directory.
How to prevent this?
git submodule deinit .
may do the trick
It seems the easiest way is manually deleting the submodule directories. The price is you have to git submodule init && git submodule update
after every checkout.
To match the directories from .gitmodules
:
grep path .gitmodules | sed 's/.*= //'
*From Prelang/gist/git-submodule-names
To remove it:
grep path .gitmodules | sed 's/.*= //' | xargs rm -rf
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