Handling empty folders

suggest change

Git does not recognize folders, only files and their paths. Git does not track empty folders. SVN does. With git-svn, by default, empty-folder changes you make in Git are not propagated to SVN.

The --rmdir flag on dcommit removes an empty folder in SVN when you delete the last file inside it:

git svn dcommit --rmdir

Unfortunately it does not remove existing empty folders: you need to do that manually.

To avoid adding the flag each time you do a dcommit, or to play it safe if you are using a git GUI tool (like SourceTree) you can set this behaviour as default with the command:

git config --global svn.rmdir true

This changes your .gitconfig file and adds these lines:

[svn]
rmdir = true

To remove all untracked files and folders that should be kept empty for SVN use the git command:

git clean -fd

Please note: the previous command removes all untracked files and directories, including ones SVN would keep as empty folders. To recreate the empty folders tracked by SVN:

git svn mkdirs

In practice, if you want to clean untracked files and folders and still keep SVN’s empty folders, run both commands:

git clean -fd && git svn mkdirs

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents