Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-svn merge 2 svn branches

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

like image 552
dimba Avatar asked Apr 22 '10 19:04

dimba


People also ask

Can we merge two branches in svn?

In the From URL option, you should specify the branch to which you want to merge. For example, assume that there are 2 branches, branch A and branch B , and you want to merge branch B to branch A . In TortoiseSVN, click on Merge option and then select Merge two different trees option.

How do I merge 2 branches in git?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.

Can you merge multiple branches in git?

Git merge is a powerful command that will allow you and your team to use different branches to work on new features, and then bring them together to your main repository.


1 Answers

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.

like image 60
VonC Avatar answered Sep 28 '22 02:09

VonC