跳至主要內容

高级合并

Mr.Song2022年8月8日...大约 1 分钟GitGit软件

Squash merge

通过使用 --squash 选项,你可以在合并中将多个 commit 合并为一个。

也就是对于以下的例子

mainfeaturemain1feature1main2feature2

git merge feature 得到的结果为:

mainmain1feature1main2feature2merge commit

而如果 feature 分支意在实现一个完成的特性,两个 commit 只是工作进度实际上并不重要的时候,我们可以通过 git merge --squash feature 得到:

mainmain1main2squash merge result

Cherry pick

有些时候,我们可能需要提取其他分支的某个 commit,这个时候我们可以用 cherry pick 进行操作。

mainmrhope0-a24ad1efeatureA 20%featureA 40%bug fixfeatureA 60%featureA 80%cherry-pick:bug fixfeatureA 100%

在这种情况下,我们可以回到 main 分支,执行 git cherry-pick <commit id> 来挑拣某个提交,当然,你可以一并在命令中提交挑拣多个 commit。

mainmrhope0-045d04cfeatureA 20%featureA 40%bug fix1featureA 60%bug fix2featureA 80%cherry-pick:bug fix1cherry-pick:bug fix2featureA 100%
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.3.2
温馨提示
🚀热烈欢迎各位小伙伴🚀

Your primary language is en-US, do you want to switch to it?

您的首选语言是 en-US,是否切换到该语言?