R's Workshop

Gerrit Submit Types vs. Git Commands

使用 Gerrit 管理 git projects 時, 使用者的 commit 會先 push 到一個 review branch, 形成一個 Gerrit change. 等 review 和 CI 流程跑完 (reviewed+2/verified+1), 使用者從 Gerrit submit change 後, commit 才會正式 submit 到 git repository 中. (注意: 雖然使用的動詞都是 submit, 但 Gerrit 管理的是 changes, git 管理的是 commits.) Gerrit 提供了數種 submit (change) types 來操作 commits 合回 git repository 的方式. 以下用表格比較與說明 Gerrit submit types 對應的 git commands 操作.

Gerrit Submit Types vs Git Commands

Gerrit Submit Types Git Commands
Fast Forward Only git merge –ff-only REVIEW_BRANCH
Merge If Necessary git merge –ff REVIEW_BRANCH
Always Merge git merge –no-ff REVIEW_BRANCH
Cherry Pick git cherry-pick REVIEW_BRANCH
Rebase If Necessary git rebase REVIEW_BRANCH
Rebase Always git rebase –no-ff REVIEW_BRANCH (???)

Reference

Git Gerrit