你常常會面臨着將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/
本文版權歸做者和博客園共有,歡迎轉載,但未經做者贊成必須保留此段聲明,且在文章頁面