git - 将 git 分支合并到另一个源
问题描述
我从 branch_1 创建了一个功能分支,然后从 branch_1 创建了 branch_1.1。现在我想将我的功能分支的更改合并到 branch_1.1,这样做的正确方法是什么?(我不介意将功能分支中的所有提交压缩为一个提交)
解决方案
假设现在的提交历史如下:
master branch_1
| |
...---A---...---B---...---C branch_1.1
\
D---...---E feature
您可以通过以下方式直接合并feature
分支branch_1.1
:
git checkout branch_1.1
git merge feature
提交历史将是:
master branch_1
| |
...---A---...---B---...---C---M branch_1.1
\ /
D---...---E feature
或者您可以与 squash 和 rebase 合并:
git checkout feature
git pull origin branch_1.1 --rebase --squash
git checkout branch_1.1
git merge feature
提交历史将是:
master branch_1
| |
...---A---...---B---...---C---S branch_1.1, feature
推荐阅读
- angular - Angular 登录表单让我可以使用任何用户名和密码对
- python - 有谁看到图形断开连接来自哪里?
- sql - Heroku DataClip 无法检索某些表的数据
- azure - QnA Maker 我的知识库下拉列表包含禁用的项目
- xaml - LineBreakMode - 它如何与 xamarin.forms 中的 SfRadioButton (syncfusion) 一起使用?
- c# - Input.inputString 但按下了多个按钮
- javascript - 您如何将 websocket 设置为外部 API?
- android - OnClickListener 优先级?
- python - 提高性能的 Numpy 矢量化
- android - Pepper 机器人模拟器没有启动