你常常会面临着将dev分支或者不少零散的分支merge到一个公共release分支里。git
可是有一种状况是须要你处理的,就是在你的dev的分支里有不少commit记录。而这些commit是无需在release里体现的。3d
develop 主分支blog
develop主分支最近的一个commit是”fix imageprint bug.”。咱们拉出一个分支进行项目开发,里面会有不少commit记录。开发
git checkout -b develop_newfeature_ImportDataInterface origin/developget
develop_newfeature_ImportDataInterface 分支的commit log是和develop是如出一辙的。咱们添加点修改commit。博客
如今咱们须要将develop_newfeature_ImportDataInterface 分支的commit merge到develop主分支里去。在合并进develop的时候咱们但愿在develop里的commit log里只看见一次commit,并且这个commit的message不是很随意的,而是符合正规提交流程的约定格式的,好比,”develop:finished import data interface”。it
咱们就须要借助git merge –squash命令参数来从新准备提交。(这是一个明确的merge操做不一样于git rebase,不要搞混淆这两个命令的做用。)io
git merge --squash develop_newfeature_ImportDataInterfaceast
Updating cc1fea6..e6fb522
Fast-forward
Squash commit -- not updating HEAD
1.txt | 3 +++
1 file changed, 3 insertions(+) import
--squash 会暂停commit提交。要否则一个merge会自动提交commit。
1.txt文件是咱们修改的文件,它如今待commit。如今咱们只须要从新提交便可。
git commit -m'develop:finished import data interface'
这样每次merge就会很清爽,一目了然,就算回头reset也方便。
做者:王清培
出处:http://www.cnblogs.com/wangiqngpei557/
本文版权归做者和博客园共有,欢迎转载,但未经做者赞成必须保留此段声明,且在文章页面