Moving a single subfolder is significantly more work than moving the entire repository. Overall the steps are:
- Create author mapping file
- Clone SVN into a temporary Git repository
- Convert svn:ignore properties to .gitignore file
- Rewrite the Git index file to update subfolder paths (this is required to preserve file history)
- Add a remote origin in the Git repository that files are being merged into
- Fetch and merge the remote Git repository files from the temporary Git repository
So lets see this step-by-step. I'm going to assume the following:
Create the author mapping file. This will generate a file called authors-transform.txt which contains SVN authors with their Git author equivalents. The default value for the Git author is set to 'User <[email protected]>' so adjust that if you care about having real author information.
Clone the SVN repository into a temporary Git repository and fix up remote references. Note that I set the trunk to the current directory since we are only cloning a single folder from SVN.
Transform svn:ignore properties to the .gitignore file. Note this is put into a new directory that has the same name as the subfolder that was cloned.
Rewrite the Git index so that the SubFolder appears in the correct location while preserving file history. This essentially moves all files that were cloned from SVN into a new directory called SubFolder and fixes Git history to point to the right files there. I know the documentation provides a sed example of this, however I was doing it on OS X so had to use awk instead.
In the Git directory add a remote to the temporary Git directory we just created, fetch and merge the files, then remove the remote reference.
Now you can finally push the change to the target Git repository.
The temporary Git repository can be removed at this point.