如何使用命令对 gerrit 更改进行变基?

How to rebase a gerrit change using commands?

我有一个与 master 有合并冲突的 gerrit 更改,当我挑选更改时,它说

error: could not apply 0819af2... Test change
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
# now git status is as below...
$ git status
## master...origin/master
UU path/to/file

我通常在编辑器中打开冲突文件,解决冲突并将更改上传到 gerrit(它被修改),但是如何使用脚本进行 rebase 以便它总是从 gerrit 中选择更改(覆盖本地存在的任何内容 - 通常是主人),所以我可以在没有人工干预的情况下上传 gerrit 更改?这是我喜欢做的事情:

git clone a project
apply the gerrit# 1234, if there is conflict, pick the changes from change #1234, overwriting whatever is cloned in current working dir.
Amend the gerrit, so it is rebased now.

您应该能够 force a cherry-pick resolution

git cherry-pick <sha> --strategy-option theirs
git cherry-pick <sha> -X theirs

这样,您就可以将该步骤集成到脚本中,然后 运行 无人值守。