git svn工作流程 - 功能分支和合并 [英] git svn workflow - feature branches and merge
问题描述
我现在在使用git-svn并使用以下工作流程:
git clone< SVN TRUNK URL> #done once b $ b
随后当我使用功能时
git分支功能Z
git checkout功能Z
#make编辑功能Z
git commit
git checkout master
git svn rebase#从服务器获取更改
git checkout featureZ #go返回分支
#git合并master
git rebase master#从SVN->获取更改;现在就掌握分支。可选,如果我想分支是最新的。 (编辑:从下面给出的答案)
#make编辑featureZ
git commit #featureZ完成
git checkout master
git merge featureZ #将featureZ集合到master上。准备发送给SVN
git svn dcommit #push featureZ返回SVN
现在有一些注意事项,当我把特性合并到master上时,featureZ分支中的所有单独提交合并为一个,这对我来说很好。
提交消息被替换为与featureZ合并。这可以通过 merge fmt msg 。 现在我的问题是 SVN无法处理非线性历史记录(它根本没有它的标记)。因此,你想要做的是代替合并来代替合并,因为它保留了SVN的线性历史记录(这在git-svn手册页 here 。 详细来说,线性历史是微不足道的。它们沿着一条直线(A到B到C到D),而非线性的历史可以从(A到B到C,B到D然后C + D到E - 换句话说,它们脱落成分支)。 Rebasing会给你一个线性历史记录,记住你应该从你的私人本地分支来完成rebase。例如,如果你有2个分支:master和experimental,你可以签出实验并做'git rebase master'最好带-i标志,反过来也可能导致不良的副作用。 然后你签出master并合并实验分支,你的历史应该保持线性。 I am using git-svn with the following workflow now subsequently when I work on a feature Now some points of note when I do git merge of feature onto master, all the individual commits in featureZ branch gets merged as one which is fine with me. The commit message is replaced as "merged with featureZ". That can be fixed with merge fmt msg. Now my question is
Is there anything that can go wrong with this workflow or needs to be taken care of. I read in git-svn manual that merge should not be done when working with git svn. Is what I am doing in my workflow is what that they are referring to? if so what kind of problem will it cause? One thing is I don't want to do something that messes with the SVN mainline. SVN cannot handle non-linear history (it simply has no notation of it). So what you want to do is a rebase instead of a merge as it preserves linear history with SVN (this is indicated in on the git-svn man page here. To elaborate, linear histories are trivial. They go in a straight line (A to B to C to D). Whereas non-linear histories can go from (A to B to C, B to D then C + D to E--in other words, they off sprout into branches). Rebasing will give you a linear history. Remember that rebases should be done from your private local-only branches. For instances, if you have 2 branches: master and experimental. You would checkout experimental and do 'git rebase master' preferably with the -i flag. Doing it the other way around may result in undesirable side effects. It is then you checkout master and merge in the changes from the experimental branch. Your history should remain linear. 这篇关于git svn工作流程 - 功能分支和合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
这个工作流程是否有任何问题或者需要照顾。我在阅读 git-svn手册时认为在使用git svn时不应该进行合并。我在工作流中所做的是他们所指的是什么?如果是的话,会造成什么样的问题?有一件事是我不想做一些与SVN主线混淆的东西。
git clone <SVN TRUNK URL> #done once
git branch featureZ
git checkout featureZ
#make edits for featureZ
git commit
git checkout master
git svn rebase # fetch changes from server
git checkout featureZ #go back to branch
#git merge master
git rebase master #get the changes from SVN->master onto the branch now. Optional if I want the branch to be current. (EDITED: Got from the answer given below)
#make edits for featureZ
git commit #featureZ completed
git checkout master
git merge featureZ #getting featureZ onto master. Prepare to send to SVN
git svn dcommit #push featureZ back to SVN