Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to synchronise remote branches with trunk using git-svn

Tags:

git

git-svn

I'm using git-svn to work against svn repository. The layout is standard, and I have created the local repository with:

$ git svn clone -s http://mysvnrepo
(master)$ 

I need to work on a remote (svn) branch - MyBranch, so I created a local branch to track the remote one:

(master)$ git checkout -b localMyBranch remotes/MyBranch
(localMyBranch)$

I keep working and committing to the local branch as I go, and occasionally I do dcommit:

(localMyBranch)$ git svn dcommit

Meanwhile other people are working on the trunk, and from time to time I want to merge back the changes from trunk to my branch to keep them in sync. That's where I get really confused, as I could not find a good information how to perform this. So far I know that I need to do:

(localMyBranch)$ git svn dcommit
(localMyBranch)$ git checkout master
(master)$ git svn rebase

Now what? I read that this is NOT the right way to go:

(master)$ git checkout localMyBranch
(localMyBranch)$ git rebase master

As it's going to mess the merge info for svn.

So what is the best way to "rebase" my remote svn branch to the remote trunk, preserving the merge info for svn?

like image 801
Sunny Milenov Avatar asked Feb 07 '12 13:02

Sunny Milenov


People also ask

How does SVN compare to trunk and branch?

- A trunk in SVN is main development area, where major development happens. - A branch in SVN is sub development area where parallel development on different functionalities happens. After completion of a functionality, a branch is usually merged back into trunk.

Does SVN support branching?

Subversion Branching StrategiesSubversion branches (SVN branches) allow your team to work on multiple versions of your code simultaneously. Developers can test out new features without impacting the rest of development with errors and bugs. SVN's “branch” directory runs parallel to the “trunk” directory.

How do I create a branch in SVN trunk?

To create a branch or a tag in a Subversion repository, do the following: From the main menu, choose VCS | Subversion | Branch or Tag. Alternatively, select the source folder in the SVN Repositories tool window and choose the Branch or Tag command from the context menu.


1 Answers

You'll want to create a local working branch to handle your merge. The key is that you need a branch that is not actively tracking a remote svn branch.

Try this:

(localMyBranch)$ git checkout -b merge_work
(merge_work)$ git merge master
(merge_work)$ git checkout localMyBranch
(localMyBranch)$ git rebase merge_work

and vice-versa for merges the other way.

EDIT

If you are using git-svn 1.7.7 or higher, there is a configuration setting to tell git-svn to populate the mergeinfo property on the remote repository:

git config --global svn.pushmergeinfo true
like image 108
Peter Bratton Avatar answered Sep 27 '22 23:09

Peter Bratton