Gitlab 在處理提交的 Merge Requests 時(shí),默認(rèn)情況下是使用正常的merge后在提交一次风秤,相當(dāng)于git merge --no-ff
但如果要合并的分支 commit 記錄比較多的話會(huì)使得 master 分支的log 版本會(huì)非常多骨稿,使用 git log 做追溯的時(shí)候比較難抓住重點(diǎn)笨鸡。
期望master分支內(nèi)只展示提交 Merge Request 時(shí)的描述內(nèi)容,將全部的 commit 合并成為一條記錄坦冠,相當(dāng)于git merge --squash && git commit
經(jīng)過各種試驗(yàn)形耗,最終發(fā)現(xiàn)gitlab merge 時(shí)使用的方法是(根據(jù)版本路徑可能會(huì)稍有不同,我這使用的版本是 GitLab Community Edition 10.7.3
)
找到下面這個(gè)文件
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb
將 rugged_merge 內(nèi) option 的配置做如下修改
parents: [our_commit, their_commit] 去掉 their_commit
修改后即為
options = {
#parents: [our_commit, their_commit],
parents: [our_commit],
tree: merge_index.write_tree(rugged),
message: message,
author: committer,
committer: committer
}
修改完畢之后記得重啟gitlab gitlab-ctl restart
下面就可以測(cè)試效果了
比如新建一個(gè)分支辙浑,并在該分支內(nèi)提交多次commit激涤。
然后在gitlab上提交如下的 Merge Request
merge 成功后,在master分支使用 git log
查詢判呕,最新的一次 commit 記錄展示為在master上展示的內(nèi)容