Say your bug fix branch is called bugfix
and you want to merge it into master
:
(假设您的错误修复分支称为bugfix
并且您希望将其合并到master
:)
git checkout master
git merge --squash bugfix
git commit
This will take all the commits from the bugfix
branch, squash them into 1 commit, and merge it with your master
branch.
(这将从bugfix
分支中获取所有提交,将它们bugfix
为1个提交,并将其与您的master
分支合并。)
Explanation :
(说明 :)
git checkout master
Switches to your master
branch.
(切换到您的master
分支。)
git merge --squash bugfix
Takes all the commits from the bugfix
branch and merges it with your current branch.
(从bugfix
分支中获取所有提交,并将其与当前分支合并。)
git commit
Creates a single commit from the merged changes.
(根据合并的更改创建一个提交。)
Omitting the -m
parameter lets you modify a draft commit message containing every message from your squashed commits before finalizing your commit.
(省略-m
参数,可以在最终提交之前修改包含已压缩提交中的每个消息的提交消息草稿。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…