一种非常简单的方法是选择提交到从master创建的新分支中的
git checkout -b widget-2 master
git cherry-pick feature..widget
# then to apply that to the real widget branch and get rid of the temp
git checkout -B widget widget-2
git branch -d widget-2
但是,考虑到我,我们本可以完全跳过临时分支:
git checkout --detach master
git cherry-pick feature..widget
git checkout -B widget HEAD
,
你有这个:
0-0-0-0-0-0 <--master
|-0-0-0-0-0-0 <--feature
|-0-0-0-0-0 <--widget
,您想将其转换为:
0-0-0-0-0-0 <--master
| |-0-0-0-0-0 <--widget
|-0-0-0-0-0-0 <--feature
git rebase命令非常灵活。您可以将git rebase
与--onto
选项一起使用来进行此操作:
git rebase --onto master feature widget
本文链接:https://www.f2er.com/3145711.html