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?

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

git checkout -f doesn't help. git clean -ffd (not submodule name) does.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.