为什么merge的时候要用squash

通常我们在用git做代码管理的时候,会在master/develope/release的基础上创建的自己的工作local branch,假设称之为“MyWorkBranch_local”。

然后我们在工作过程的中修改的代码会不断的提交到自己的local branch(MyWorkBranch_local),这样在这个branch上就会产生许多的commit。

当我们最终完成自己的代码,需要把自己branch(MyWorkBranch_local)的代码merge到master上,但是local branch上的commit的信息有时候太多,

没有必要保留过多的历史信息,只需要简洁明确的信息,这时候我们可以在master基础上再创建一个remote的branch,假设称之为"MyWorkBranch_remote",然后把local branch(MyWorkBranch_local)的代码先merge到remote的branch(MyWorkBranch_remote),并去掉历史信息,完整操作步骤如下:

1. git checkout master

2. git checkout -b MyWorkBranch_local

3. modify the codes and commit it to MyWorkBranch_local

4. git checkout master

5. git checkout -b MyWorkBranch_remote

6. git push origin MyWorkBranch_remote

7. git merge MyWorkBranch_local --squash

8. solve the confilicts

9. commit and push

10. create PR in github and merge to master/develope/release

还可以参考这篇文章,写的也很详细。

 

转载于:https://www.cnblogs.com/minstars/articles/5449422.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值