2

I need to release only certain stories that have passed QA. I don't have access to the branches, only the master branch.

There will be another release in two weeks, so I was thinking of just creating a 'dead-end' release branch and that I need to start this branch from the commit just prior to the last release and then merge, rebase or cherry pick commits from the master to put into my 'release branch'.

So I've checked out from that point 2 weeks ago and made a branch from it. Now I need to fold-in all the stuff I'm interested in. Actually, no I haven't. I don't think I have. On master, I checked out the old commit and then made a new branch but looking at the illegible history in gitk is it? (I'm on Windows) I think it made a branch from the head of master.

Any advice gratefully received. Please speak slowly, as I find Git more difficult than any other topic I've ever had to comprehend in my life, including derivatives pricing, Newtonian Mechanics, vector math, string theory and my wife, and judging by the votes Git questions get, so does everyone else.

Hoping this is pretty standard, considering that most teams will have stories that don't meet QA some some that do.

4

2 回答 2

7

如果您的master分支当前如下所示:

A---B---C---D---E---F <--master

并且,假设您要创建一个仅包含Cand的新分支E,以及直到(包括)之前的所有内容A,这是您需要做的基本计划:

git checkout -b newbranch A
git cherry-pick C E

这应该会导致这种情况:

 A---B---C---D---E---F <--master
  \
   C'---E' <--newbranch

根据A..F原始文件之间的确切依赖关系master,您可能会遇到一些必须解决的冲突(例如,如果B引入了一些东西,并C修改了一些东西,那么樱桃采摘C将找不到它想要修改的东西)。

于 2013-07-10T16:39:28.620 回答
3

另一种选择(不是挑选樱桃)是执行交互式变基。

仍然假设您的master分支当前看起来像这样:

A---B---C---D---E---F <--master

并且您想要一个带有Cand的新分支E

git checkout -b newBranch F
git rebase -i A

然后,您最喜欢的编辑器将提示并显示和之间的所有提交newBranchA不包括 A):

pick B    Message for commit B
pick C    Message for commit C
pick D    Message for commit D
pick E    Message for commit E
pick F    Message for commit F

删除与您不想保留的提交对应的行,即:B、D、F。保存并退出,让 rebase 命令完成其工作。瞧!

A---B---C---D---E---F <--master
  \
   C'---E' <--newbranch

正如 twalberg 所注意到的,您可能会在此过程中遇到冲突。在这种情况下,rebase 命令将为每个问题暂停,并邀请您解决它。完成后,只需键入git rebase --continue即可继续。

于 2013-07-10T17:03:42.010 回答