'Git bash giving error of warning: unable to rmdir

I am using git bash on windows 10 which was recently updated to creators update.

whenever i am trying to switch between branches i get following thing

$ git fetch && git checkout master
warning: unable to rmdir Ionic_Developemnt: Directory not empty
Checking out files: 100% (6312/6312), done.
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

I don't know why this is happening also there is a .git hidden folder in the Ionic_Development folder

Can anyone help with this why so error _/_



Solution 1:[1]

warning: unable to rmdir on git checkout means that you're switching to a branch where this directory doesn't exist; git tries to remove it but there are some temporary files that git cannot remove; the directory is not empty so git cannot remove it also, hence the warning.

Solution 2:[2]

This happens mostly when your files are still in use. I personally experienced this sometimes with atom editor. Try to close your editor, and maybe any running compilers that are watching for changes too, and try to checkout again.

Solution 3:[3]

Found the answer, instead of git checkout, use git checkout --recurse-submodules.

Use git config submodule.recurse true to tell git always use --recurse-submodules (only in git versions 2.14+), add --local if you want that only in local project level.

Reason: This issue happens on (Git < 2.13) when git checkout could not take care of those submodules correctly.

Reference: https://github.com/gitextensions/gitextensions/issues/2966#issuecomment-622666568


Original Answer

Actually I think this answer is partially right :O

If a folder is tracked by local .git within that folder, it would be changed according to .git when you switch branches (e.g. deleted from our point of view, if the other branch does not have this folder).

If a folder is ignored by .gitignore, the folder would be left unchanged when you switch branches.

However, if the folder is a submodule, which is tracked by submodule .git, local .git would try use rmdir when switching branches, which caused the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 phd
Solution 2 mos
Solution 3 E_net4 - Krabbe mit Hüten