开发者

git: work with git-svn when there are merges

As far as I understand, git-svn does not support pushing merge commits.

Is there a way to make it work with such commits?

We have tried to use rebase to create a linear history. Howev开发者_运维问答er, this fails with conflicts on whitespace errors. Is there a way of linearizing the history so there are no conflicts?


The simplest way of rebasing merged commits to svn is to squash them:

assuming we rebase branch dev to trunk

git checkout trunk
git merge --squash dev

you might have to fix real merge conflicts between trunk and dev. At the end you have one commit which you can well git svn dcommit.

The downside of this method is that you loose granularity of your commits in SVN. If this is a problem, you could employ a rebase-style merging strategy for git (e.g. http://unethicalblogger.com/2010/04/02/a-rebase-based-workflow.html ).


It's not straightforward, but possible.

  1. Check out your feature branch

    $ git checkout feature1
    
  2. Create a Subversion branch, preferrably with the same name and rebase your local git branch

    $ git svn branch feature1
    $ git rebase remotes/feature1
    
  3. When you push your changes, they will go to the Subversion branch, not to the trunk.

    $ git svn dcommit
    

The only way to do e merge that I am aware of is using a temporary SVN checkout and using svn merge. For merges that can be performed automatically, without conflicts, scripting the last steps (SVN repository lookup, temporary checkout, merge) has worked well for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜