将 git 分支合并到另一个源
Merging git branch to another source
我已经从 branch_1 创建了一个功能分支,然后 branch_1.1 是从 branch_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
我已经从 branch_1 创建了一个功能分支,然后 branch_1.1 是从 branch_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