views:

248

answers:

2

I'm using svn. I have two branches and on both of them were performed a lot of changes. In addition of one of the branches a lot of files were renamed, so now svn can not help me merge changes in those files (well know svn limitation).

  1. Is it possible using git-svn to perform the merge of the branches?
  2. Will git-svn handle renamed files too?

Thanks

+2  A: 

git merge should be able to detect (up to a certain point) renames.

recursive

This can only resolve two heads using a 3-way merge algorithm.
Additionally this can detect and handle merges involving renames.
This is the default merge strategy when pulling or merging one branch.

But git-svn can only import/export from/to SVN, not do the merge.
And the merge is tricky:

CAVEATS

For the sake of simplicity and interoperating with a less-capable system (SVN), it is recommended that all git svn users clone, fetch and dcommit directly from the SVN server, and avoid all git clone/pull/merge/push operations between git repositories and branches.
The recommended method of exchanging code between git branches and users is git format-patch and git am, or just 'dcommit'ing to the SVN repository.

Running git merge or git pull is NOT recommended on a branch you plan to dcommit from. Subversion does not represent merges in any reasonable or useful fashion; so users using Subversion cannot see any merges you've made. Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommit may commit to the wrong branch.

If you do merge, note the following rule: git svn dcommit will attempt to commit on top of the SVN commit named in

git log --grep=^git-svn-id: --first-parent -1

You must therefore ensure that the most recent commit of the branch you want to dcommit to is the first parent of the merge. Chaos will ensue otherwise, especially if the first parent is an older commit on the same SVN branch.

VonC
+1  A: 

i once had the same problem in a project in college. what i did was the following:

  • create a new git-svn repository (git svn clone -s https://…)
  • merge the branches with git (git checkout master; git merge branch)
  • checkout the trunk with svn (svn co https://…/trunk)
  • copy over the merged files from git
  • delete left-over files and directories with svn (svn rm)
  • commit with svn (svn ci)
  • fetch the new commit in git
knittl
Thanks for the useful summary.Was the git merge easy, any easier that doing it by svn?(I trying find an answer to this: http://stackoverflow.com/questions/2945842/using-git-svn-or-similar-just-to-help-out-with-svn-merge)
inger
One more thing, did you try to dcommit back to svn? If so, what issues were you getting/expecting?
inger
@inger, no i committed with svn to make sure i don't end up pushing half-baked merges that only git would understand.
knittl