My team moved our codebase from Google Code to GitHub previously. We avoided using GitHub’s import feature because we aimed to transfer only part of our project. Instead, we created a new GitHub repository based on our local directory containing the necessary files.
The problem I’m facing:
Now, I want to import the commit history from our previous Google Code SVN repository, but only up to a specific revision number (for example, revision 500). The challenge is that I don’t want to alter any actual code in our GitHub repository. My goal is just to integrate the historical commits to visualize the development timeline.
What I’ve tried:
I explored git-svn, but I’m unsure how to limit it to select revisions and merge it with the current code without overwriting it.
Is there a way to achieve this? Has anyone managed to import partial SVN history into an existing Git repository?
I dealt with a similar issue during a project transition from SVN to Git. A solution that worked well was utilizing git-svn to specify the revision range you want. You can use the command git svn clone -r 1:500 to create a new repository that includes only the desired commits. Then, link this repository as a remote to your existing GitHub repository and pull those commits into a separate branch, perhaps named svn-history. It’s important to avoid merging this branch with your main branches; treat it purely as a historical reference. This method allows you to visualize the commit history while keeping your current codebase intact and unaffected.
I had a similar situation and used git filter-branch after doing the git-svn import. Here’s what worked: I cloned the whole SVN repo with git-svn, then made a separate Git repo from it. The trick was using git filter-branch to pull out just the revision range I wanted while keeping all the commit metadata and timestamps intact. Then I added that filtered repo as a remote to my existing GitHub repo and fetched those historical commits into their own branch. This way I got full control over which commits to include and didn’t mess with my active branches at all. Got the exact historical view I needed without any risk to my current code.
I saved tons of time using git subtree after my initial git-svn conversion. I imported the SVN history up to where I needed it, then ran git subtree add to pull those commits into a subdirectory of my existing GitHub repo. Git subtree keeps the original timestamps and author info while everything stays in one repo. You can still use git log with paths to see just the historical stuff when you need it. This approach cuts out all the headache of multiple remotes or replacement refs, and GitHub’s network graph shows the full timeline naturally. The old commits become part of your permanent history without messing with your current workflow.
just did this last month! i used git svn with --prefix to avoid conflicts. cloned svn up to rev 500, created an orphan branch in my github repo, then cherry-picked the commits i wanted. worked perfectly and didn’t mess with my main code.
Here’s what I did: I cloned your SVN history into a separate Git repo first, then connected it to your existing GitHub repo. After running git-svn clone with your revision limit, use git replace to link the SVN history endpoint with your GitHub repo’s first commit. This gives you a seamless timeline view without touching any files or branches in your current repo. The git replace trick makes Git treat both repos as connected for history viewing, but keeps your actual code completely separate. You’ll have to push the replacement refs to GitHub separately, but once that’s done, your commit graph shows the full timeline from SVN all the way to your current work.