Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using git-svn to merge a svn branch back into trunk and trunk back into the branch

So I'm using git and interacting with an svn repo.

I have a svn TRUNK that looks like this:

A-B-C-D

And a svn bug_fixes branch that branches off at commit B or C:

 -c-d-e-f-g-h-i

Now I need to get the cdefghi commits that are in my svn branch back into the master branch.

I'm aware that I could just do a squashed commit, let's call it squash SQUASH (which would contain cdefghi), but then it seems like I would have to kill the bug_fixes branch and start a new branch to cleanly continue.

Here: http://blog.red-bean.com/sussman/?p=92 they suggest:

checkout the branch.

merge master's changes into the branch.

Checkout the master.

merge --reintegrate the branch's changes onto master.

Continue development.

Unfortunately, git-svn doesn't seem to recognize any "merge --reintegrate" command for svn.

So how do I cleanly make branch and master have all commits, so that development on both can continue, using git-svn's commands?

like image 878
Kzqai Avatar asked Jan 29 '10 19:01

Kzqai


People also ask

How do I merge two svn revisions?

To merge a range of revisions, use svn merge -r start:end from to where start and end are revision IDs. This will merge all revisions starting at start+1 up to and INCLUDING end . Note: it will NOT include the first revision (ex: -r3:45 will merge 4 through 45).

What is a svn Sync merge?

This basic syntax— svn merge URL —tells Subversion to merge all changes which have not been previously merged from the URL to the current working directory (which is typically the root of your working copy).


1 Answers

The Caveats section of the git-svn documentation warns

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 author does provide a recommendation:

The recommended method of exchanging code between git branches and users is git format-patch and git am, or just dcommiting to the SVN repository.

Adapting to your situation

git format-patch --stdout c^..i >my.patch
git reset --hard trunk
git am <my.patch

where c and i are appropriate identifiers for the commits in your history.

like image 193
Greg Bacon Avatar answered Sep 27 '22 17:09

Greg Bacon