git - git rebase 并重置对源分支的提交
问题描述
我想改变我my-branch
的staging-branch
A---B---C---D---E staging-branch
\
A5---A4---A3---A2---A1 my-branch
变基后,我想得到他们所有的提交,然后是我的。
A---B---C---D---E staging-branch
A---B---C---D---E---A5---A4---A3---A2---A1 my-branch
然后我想将所有提交合并为两个提交。
A---B---C---D---E---A11---A22 my-branch
我可以使用以下命令将所有提交分组为一个,但不确定如何将其分成两个。
git reset --soft HEAD~5
git commit --edit -m"A11"
git push origin my-branch
谢谢
解决方案
您可以使用交互式 rebase根据您的逻辑对提交进行重新排序,并将它们压缩为两个单独的提交。整个事情看起来像这样
git checkout my-branch
git rebase staging-branch
git rebase -i // reorder the commits and use squash to merge them and save the file
推荐阅读
- r - 如何从 ggplot 获取(未设置)轴最小值和最大值?
- r - 使用 keep、discard 和 filter 将数据帧保留在数据帧列表中
- angular - CombineLatest 导致多个流提交
- python - 如何在 Python 中计算很长的数字
- javascript - React Router:单击链接时如何在 URL 中保留参数
- go - 不会在终端上打印任何内容
- if-statement - Power Bi 中多场景的查找值
- python - 如何在日志记录中包含 python django 的启动消息
- angular - 通过实体表示正确使用 subscribe() 到 Observable
- azure-devops - YAML 管道与默认 Azure 管道中的输出不一致