This short post is intended to serve as a warning about a potential gotcha with git-svn, and how to prevent it.
First, a sort of “postmortem” of my run-in with this issue:
I was working to migrate an old SVN repository full of documents to Git. We had decided that we didn’t need to maintain a complete history going forward, that we would just take what was currently there and put it in a new Git repository. We would keep the old SVN repository around for reference in case we ever did need to go back through that older history. We wanted to preserve the old history in SVN, but make a clean break from it for a fresh start with a new Git repo.
I used SVN to check out a fresh copy of the repo, removed
.svn, turned the directory into a Git repo, and pushed it out to the new remote. All good there.
Then, I went to clean up the old SVN repo, to make it obvious that it had moved. I went to where I had my regular working copy checked out (with git-svn), deleted everything, added a README with information about the decision to move to Git, committed, and used
svn dcommit to push the change to our SVN server.
Little did I realize, my commit to “delete everything” had skipped over an important class of somethings: directories.
Since Git has no concept of directories as anything more than components of the paths to files, my local (git-svn) copy looked correct (only a README left), but the commit made to SVN had removed only files and not any directories.
Unsurprisingly, this led to confusion later when others updated their local copies and most things appeared to still be there. This was exacerbated by the fact that many of the documents checked in are actually bundles (e.g. iWork documents) and thus still appeared to be present.
Thanks to a post from Peter Boling (no longer available), I’ve learned that I should have made my dcommit with the
To avoid this issue altogether Boling also suggests modifying your
~/.gitconfig to make this the default:
[svn] # push empty directory removals back to svn as directory deletes rmdir = true
Another post on this topic mentions the difference of option between Git and SVN about directories causing problems when working with ASP.NET MVC. Hopefully, adding another voice to these words of caution will save someone this pain.
Beware: If you don’t set
rmdir when making commits with
git-svn, you might be leaving empty directories on the server and not even know it! Change your