从...开始
hack---F1----M1----F2 (feature)
/ /
C1-----C2----C3 (master)
Run Code Online (Sandbox Code Playgroud)
我想结束
hack---F1----M1----F2 (feature)
/ /
C1-----C2----C3---F1'---F2' (master)
Run Code Online (Sandbox Code Playgroud)
到目前为止,我所拥有的最好的是
git checkout feature
git checkout -b temp
git rebase -i --onto master hack temp
* Big drawback: manually remove the merged-in C2 and C3 from list of commits *
git checkout master
git merge temp
git branch -d temp
Run Code Online (Sandbox Code Playgroud)
我希望有人能回答,即使这是一个可疑的工作流程.
jub*_*0bs 15
如果您的回购状态是
hack---F1----M1----F2 [feature]
/ /
C1-----C2----C3 [master]
Run Code Online (Sandbox Code Playgroud)
而你想要到达
hack---F1----M1----F2 [feature]
/ /
C1-----C2----C3----F1'----F2' [HEAD=master]
Run Code Online (Sandbox Code Playgroud)
你应该使用git cherry-pick,而不是git rebase -i(不需要在这里使用交互式rebase):
git checkout master
git cherry-pick <commit-ID-of-F1> <commit-ID-of-F2>
Run Code Online (Sandbox Code Playgroud)
纠正我,如果我错了,但我明白你的意思一般情况下,如
最重要的是
master,hack(独家)和feature(包括)之间的所有非合并提交.
在下面,我假设这确实是你的意思.
正如您在评论中正确指出的那样,上面概述的方法不能非常优雅地扩展,因为手动挑选的提交数量会增加:
hack---F1---F2--- .... --- F68--M1---F67---...---F99 [feature]
/ /
C1-------------C2---------------C3 [master]
Run Code Online (Sandbox Code Playgroud)
但是,您可以git rev-list使用自动生成感兴趣的修订列表
git rev-list --reverse --no-merges --first-parent <commit-ID-of-hack>..feature
Run Code Online (Sandbox Code Playgroud)
编辑:您还需要该--first-parent标志以避免收集诸如C1和C2,并且--reverse标记的提交,以便提交以所需顺序进行挑选.
您可以将该命令的输出传递给git cherry-pick:
git checkout master
git cherry-pick `git rev-list --reverse --no-merges --first-parent <commit-ID-of-hack>..feature`
Run Code Online (Sandbox Code Playgroud)
会产生的
hack---F1---F2--- .... --- F68--M1---F67---...---F99 [feature]
/ /
C1-------------C2---------------C3---F1'---F2'---...---F99' [HEAD=master]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4650 次 |
| 最近记录: |