I have three branches on my local machine:
- master
- feature-branch-with-submodule
- feature-branch-without-submodule
The branch without submodule used to have a submodule, and I removed the submodule by following instructions from this SO post. I did not want to remove submodule from master
and feature-branch-with-submodule
.
However, now that I am done with feature-branch-without-submodule
, I want to switch to feature-branch-with-submodule
. So I do git checkout, but got the error:
fatal: not a git repository: src/vendor/mysubmodule/../../../../../.git/modules/src/vendor/mysubmodule
How do I fix it so that the branch with submodule has it, and the branch without does not, and that I can freely switch back and forth using git checkout?
git checkout --recurse-submodules
is not enough you should consider usingpost-checkout
hook like these. – Leg