0

So my team is currently using an svn repository for our project. There has been another team working in parallel but they are using a git repository. I want to take the other team's code and merge it onto ours. I have already tried a few times but I keep pulling their code without merging, i.e. it just overwrites our files. I have been using the git-svn tool and have found little success and I'm afraid that the increasing number of useless and garbage commits in our svn log isn't going to look good in front of my boss.

These are a few of the obstacles that have been in my way:

  • We have a single svn repository with about 10 components inside, where the other team has a repo for each component.
  • I've been following an example that uses the -s option, which is short for standard layout (svn common directory structure using trunk/branches/tags) which our svn repo does not have. I have not been able to get this method to work without this option, which leads to all the files getting merged (basically just copied) into an empty directory that I don't care about.
  • Preferably, I would not want to keep their entire commit history. I just want a single commit saying that I merged their repo with ours. Or a commit for each of their git repos I have to merge. The same example mentioned in the previous bullet copied the entire commit history which added a ton of commits to our log which my team does not care about.

Here is the example (first answer in this post):

mkdir copy-git-repo
cp -a orig-git-repo/. copy-git-repo/
cd copy-git-repo/
svn mkdir --parents https://svn/url/PROJECT/trunk -m "Trying to merge of of their git repos into our svn"
git svn init https://svn/url/PROJECT -s
git svn fetch
git rebase trunk master
# if there are merge conflicts
git status
# deal with merge conflicts listed 
git add .
git rebase --continue
git svn dcommit 

Does anyone see a mistake that I've made?

1 Answers1

0

If what you are used to do is svn, I would advice you to go with svn straight (even though I hate it). So.... if you take a look at the other team's repo (the one that is being worked on git), can you map svn revisions (from your svn repo) to revisions on the git repo... and I mean, 1 to 1, not close revisions. It needs to be exact matches of revisions.

Suppose you want to merge git branch X (from their repo) into your trunk branch (from your repo). If you can find an ancestor of X that is equivalent 1 to 1 to an ancestor of your trunk, then you could:

  • create a branch on your svn repo that starts on the ancestor that we are talking about
  • Remove all files from the project on this branch (do not commit)
  • Get a copy of the content of branch X (on the git repo..... content at the very tip of X) and put it inside the branch. And now commit on svn. At this point, the revision you just created has all the differences between the ancestor of X that you were able to see on both git and svn and the tip of branch X.
  • Now, you can take this branch you created and try to merge it into trunk.

As a last piece of advice (and this is me being opinionated, sorry): consider jumping to git for good. It takes a little bit of effort to get used to the differences from svn... but you won't regret it.

eftshift0
  • 26,375
  • 3
  • 36
  • 60