itsadok
itsadok

Reputation: 29342

git-svn branch - How to keep branch in sync with trunk?

There are plenty of questions about git-svn workflow, but I haven't been able to figure this one out:

This section of the svn book talks about a common practice with SVN: you make a branch, and you keep merging changes from the trunk as the trunk gets updated, so that the branch always includes the latest changes.

I did git svn branch to create a branch on svn and then set up a tracking branch to work on it. These questions cover the process pretty well.

Now suppose there were changes made to the trunk, which I now want to merge into the branch. What is my best option? Note that I need to keep git-svn happy, and not mess up the work of people using the branch with subversion, so just doing a rebase would probably not work.

This question seems to talk about a similar situation, although it's pretty old, and I'm not sure what the bottom line there was - it seems to suggest I should git checkout master and then git rebase mybranch, but that can't be right.

I suspect the the answer should be something that has the effect of svn merge, preferably with setting the mergeinfo property, but alas, there is no git svn merge...

Upvotes: 4

Views: 2116

Answers (1)

itsadok
itsadok

Reputation: 29342

I don't really understand how this simple question was left unanswered for more than a week, with only 13 views so far. I guess it was my fault, bad question writing.

Anyway, I figured it out myself. Short version: just use git merge instead of git rebase.

My confusion came from using git rebase when syncing a branch with the changes in master. When working on local branches, this usually works great, and keeps the history clean. However, you should not rebase commits that you have pushed to a public repository, and the subversion repository is (apparenly) public enough. git merge, on the other hand, works beautifully, and doesn't have any problem.

So, the long answer is: when you want to merge the latest changes in the trunk into the svn branch you're tracking, just do:

git merge master
# Handle conflicts, git add when you're done
git commit
git svn dcommit

This will keep your branch in sync with trunk, but will not set mergeinfo, so you probably should not mix svn merge with this kind of practice.

Upvotes: 2

Related Questions