1

I have a submodule on a development branch that isn't present on other branches. Everytime I switch branches I get a message like this:

warning: unable to rmdir master/images/development/fakeapi: Directory not empty

When I look in the directory the submodule files are still there even when I've switched to the branch with no submodule.

Is there a way to deal with this so I don't have to manually remove the submodule files after switching branches?

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225

1 Answers1

2

That seems to be documented in Issues with Submodules and it involves by default some manual command.

Switching branches with submodules in them can also be tricky.
If you create a new branch, add a submodule there, and then switch back to a branch without that submodule, you still have the submodule directory as an untracked directory

Solution: git clean -ffd <submodule>

If you do remove that directory and then switch back to the branch that has that submodule, you will need to run submodule update --init to repopulate it.

You have more on those operations in "Working with Git Submodules in MantisBT"

Is there a way to deal with this so I don't have to manually remove the submodule files after switching branches?


Is there a way to deal with this so I don't have to manually remove the submodule files after switching branches?

Check if git checkout -f can help

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250