How can I remove empty directories in git-svn?

It is a bit rough, but I have found that the following solves my problem:

rm .git/svn/refs/remotes/trunk/unhandled.log
git clean -df

Any subsequent

git svn rebase

will not recreate anything.

Since I don't know how to regenerate this file without re-cloning the repo, I suggest making a backup of it first. It is a text file, so I suppose you could also edit its content to remove the entries that end up creating


I think you'll find your answer in this blog post.

[...]

Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not removed by default if there are no files left in them. git cannot version empty directories. Enabling this flag will make the commit to SVN act like git. config key: svn.rmdir

To fix the root of the problem set the git config globally:

git config --global svn.rmdir true

[...]


Tell git svn that it should not try to recreate empty directories:

git config svn-remote.svn automkdirs false

This is the relevant section of the man page:

svn-remote.<name>.automkdirs

Normally, the "git svn clone" and "git svn rebase" commands attempt to recreate empty directories that are in the Subversion repository. If this option is set to "false", then empty directories will only be created if the "git svn mkdirs" command is run explicitly. If unset, git svn assumes this option to be "true".

Note that it is easy to confuse this topic with the topic of committing/not committing empty directories to SVN (which is what svn.rmdir is for).


Answer via https://spin.atomicobject.com/2014/08/17/git-svn-empty-directories/:

Modify your ~/.gitconfig to add this as default behaviour.

  [svn]
  # push empty directory removals back to svn as directory deletes
  rmdir = true

This will make removing directories the default.

Tags:

Svn

Git

Git Svn