git svn – Subversion repository moved, what should I do?

As I prefer Git as version control system I often end up working with it as client for Subversion (SVN) repositories. Recently, I had to interact with a SVN repository which was moved to another location after my initial cloning.

As Git stores the SVN URL and includes it into the SHA-1 hash calculation you can end up having the following problem as soon as you change the repository URL and try to push your changes to the remote repository:

Unable to determine upstream SVN information from HEAD history.
Perhaps the repository is empty. at /usr/libexec/git-core/git-svn line 519.

The problem is that by changing the SVN repository URL calculated SHA-1 hashes differ and Git cannot determine the proper commit to push to. In order to overcome these problems you can add the rewriteRoot option to your configuration file and afterwards change the URL:

git config --replace-all svn-remote.svn.rewriteRoot
git config --replace-all svn-remote.svn.url

Next time you try to push your changes they will be pushed to the new repository destination (newURL) but Git pretends it to be the old repository destination (oldURL).

Leave a Reply