Question

We currently have several small semi-related SVN repos that are inactive as far as commits go. However, they occasionally need to be used and/or their commit history needs to be reviewed. We would like to move all of them into a single pre-existing Git repo as most of our work is done on Git these days...

In doing research, what I think I want to achieve is to have a Git subtree branch for each SVN repo which has all of the commit history. But, git-svn seems to only allow me to relate 1 SVN repo to 1 Git repo, so I would have to create a git repo for each project first, and then convert to a subtree in the final repo. (I think)

Is there a way to merge the history from an SVN repo directly onto a branch in my Git repository so that I can effectively skip the step of creating redundant Git repos?

Was it helpful?

Solution 2

So, the reason I was wanting to avoid extra repositories was that we are using GitHub to store our repositories and the extra repositories I would need to create would put us over the limit of our current plan.

As such, the trick, I found out, is to keep all of the repositories local. I knew this was a possibility, but wasn't sure how to reference the local repositories. It turns out it couldn't have been more easy! Here are the steps I went through:

For each SVN repository:

git svn clone http://svnhost.com/path/to/svn/repo

This will create a local Git repo with all of the history from SVN (even timestamps are preserved!!). Next, go to the repo you want to merge it in to. Create a branch, and pull in the code from:

git checkout -b newsvnbranch1
git pull path_to_newsvnbranch1_git_repo

Now, the remaining steps aren't part of the original question, but they were the end goal that I needed to accomplish - all the SVN repos and histories merged together, but in their own directories.

git mv trunk newname1
git checkout master
git merge newsvnbranch1

Completing those steps for each SVN repo essentially leaves your original Git repo with the following structure:

original
|-newname1  (containing the contents of the first SVN repo)
|-newname2  (containing the contents of the second SVN repo)
|-newname3  (and so on...)

And, git log will now show the history of each repo intertwined.

OTHER TIPS

Everything is easier in git. I'd use a tool like git2svn to import the Subversion repositories into git.

Once in git, you can setup a new repository with branches. You could set up each branch to track one converted Subversion repository. Once you've fetched the change sets, you can clear the remote tracking with git remote remove. That leaves you with a repository with the various changesets from Subversion on branches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top