使用git svn clone迁移大SVN仓库时出错,求解决建议
Hey there, I’ve wrestled with migrating massive SVN repos to Git more times than I can count, and that "long run then crash" issue is super common—let’s walk through actionable fixes to get you past this.
Right now you just know it crashed, but the specific error message is key to fixing this. Rerun your clone command with verbose logging to see where it’s failing:
git svn clone --verbose https://your-svn-repo-url/ your-target-git-repo
Pay close attention to the last 10-20 lines of output—this will tell you if it’s a network timeout, permission issue, corrupted SVN revision, or something else.
Large SVN repos with thousands of revisions often choke when you try to pull everything in one go. Break it into smaller chunks:
- Start by cloning only the most recent N revisions (e.g., the last 1000):
git svn clone -r HEAD:1000 https://your-svn-repo-url/ your-target-git-repo - Navigate into the new Git repo, then fetch earlier revisions in smaller batches:
cd your-target-git-repo git svn fetch -r 999:1
If that still crashes, shrink the batch size—try 500, 200, even 100 revisions at a time. It’s slower, but way more reliable.
Here are the most frequent culprits and how to beat them:
- Network Timeouts/Connection Drops: SVN servers often kill long-running connections. Increase the timeout limit by adding this to your
~/.subversion/serversfile:
Or pass it directly in your[global] http-timeout = 3600git svncommand:git svn clone --config-option svn:http-timeout=3600 https://your-svn-repo-url/ your-target-git-repo - Permission or Hook Issues: If you see "permission denied" or hook-related errors, check with your SVN admin to make sure you have read access to the entire repo history, and that no server-side hooks are blocking the clone.
- Corrupted Revisions or Bad Filenames: Sometimes SVN has revisions with broken files (non-ASCII characters, invalid paths, etc.). Skip these temporarily with the
--ignore-pathsflag (use regex to target problematic paths):
You can manually fix these paths later after the main clone is done.git svn clone --ignore-paths='^path/to/broken-dir|^file-with-bad-name.txt' https://your-svn-repo-url/ your-target-git-repo
Large repos benefit from these performance tweaks:
- Disable automatic Git garbage collection during cloning (it slows things down):
Rungit svn clone --no-gc https://your-svn-repo-url/ your-target-git-repogit gcmanually once the clone is complete to clean up. - Use multi-threaded fetching (if your Git/SVN version supports it):
Start with 2-4 threads—too many can cause connection issues.git svn clone --config-option svn:fetch-threads=4 https://your-svn-repo-url/ your-target-git-repo
If the clone dies mid-run, don’t start over! Navigate into the partially created Git repo and run:
git svn fetch
It’ll pick up right where it left off, saving you hours of redundant work.
If none of this fixes it, share the exact error logs you captured with the verbose command—we can narrow it down further from there.
内容的提问来源于stack exchange,提问作者marcusds

