使用git merge --squash,让commit变得优雅

情景模拟

我们有三个分支,master,develop以及feature特性分支,假定我们开发时使用的是feature分支,我们来这里查看提交记录
使用git merge --squash,让commit变得优雅
当然,使用idea内置的Version Control也能看到
使用git merge --squash,让commit变得优雅
However,我只是想写一句话却commit了3次,就如同为了完成一个功能但是完善了很多地方(bug,逃。。),那么,如果你不想在合并分支时体现你多次commit记录的话,下面正是你想要找的东西

步骤

  1. 切换分支前,请确保你开发分支是都已commit的
    使用git merge --squash,让commit变得优雅
  2. 切换到你要合并的分支,并拉取最新的代码
    使用git merge --squash,让commit变得优雅
  3. git三连:合并,提交,推送
    使用git merge --squash,让commit变得优雅
    git merge –squash feature-1.0.0(squash前面两个短杠)
    git commit -m’信息’
    git push origin master
    注:推到GitHub则需要登陆一下

验收

查看提交记录
使用git merge --squash,让commit变得优雅