简体   繁体   English

切换SVN远程分支时维护git本地分支

[英]Maintain git local branches when switching svn remote branches

I have been using git-svn working happily along, branching for whatever, rebasing from and dcommitting to trunk and then the powers that be decided that we are going to start working out of a branch instead of trunk. 我一直在使用git-svn进行愉快的工作,为任何分支工作,从基础迁移并重新提交到主干,然后决定我们将开始从分支而不是主干工作的能力。 My question is how do I get branches that were spawned from master that was tracking trunk to rebase/merge into the new local branch that is now tracking a new branch? 我的问题是,如何获得从正在跟踪主干的master派生的分支,以将其重新定位/合并到现在正在跟踪新分支的新本地分支中?

To attempt to illustrate it, here was my setup prior to the switch (branch/repo names changed to protect the innocent): 为了说明这一点,这是我在切换之前进行的设置(分支/存储库名称已更改以保护无辜者):

Git        ->     svn
master     ->     trunk
 |-feature1
 |-feature2

Now, this is my setup 现在,这是我的设置

Git        ->     svn
master     ->     trunk
 |-feature1
 |-feature2
newDev     ->     branches/working

The problem is, I have work in those feature branches i want to get into the svn branch "working". 问题是,我在那些要进入svn分支“工作”的功能分支中工作。 What is the best way to do that? 最好的方法是什么?

I couple of months back I implmenented the git svn branch command. 几个月前,我执行了git svn branch命令。 You can use that to create new branches in your svn remote, and then work off a local git branch based on that. 您可以使用它在svn远程中创建新分支,然后基于该分支工作本地git分支。 Committing from those local branches to the right svn branches also works. 从这些本地分支机构向正确的svn分支机构承诺也可以。

If you already have the right local branch around and want to put that into an svn branch that doesn't exist yet, you can also use git svn branch . 如果您已经有了正确的本地分支,并且想要将其放入尚不存在的svn分支中,则也可以使用git svn branch Use it to create a new remove svn branch based off trunk, pull that into your git repository, and then rebase your local git branch based off your master atop of it. 使用它基于主干创建一个新的remove svn分支,将其拉入您的git存储库,然后基于它的主节点重新构建本地git分支。

What you'll end up with is a local git branch containing all your changes sitting atop a commit with a git-svn-id pointing to the branch you just created. 最后,您将得到一个本地git分支,其中包含所有更改,这些更改位于一个提交的顶部,并且git-svn-id指向您刚刚创建的分支。 When dcommitting from that, your changes will also end up in that svn branch on the remote end. 取消提交后,所做的更改也将最终保存在远程端的svn分支中。

If in doubt, there's always git svn dcommit -n , which will tell you where exactly git-svn would be committing to. 如有疑问,总会有git svn dcommit -n告诉您git-svn到底要提交到哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM