项目

一般

个人资料

操作

Gerrit

首先,您需要在 https://gerrit.lighttpd.net 注册一个用户账户(需要 OpenID),并添加您的 SSH 公钥。

检出

在您的 ~/.ssh/config 中配置 gerrit.lighttpd.net

Host gerrit.lighttpd.net
HostName gerrit.lighttpd.net
Port 29418
User <gerritusername>

检出新树

git clone -o gerrit gerrit.lighttpd.net:lighttpd/lighttpd2.git

(如果您没有配置 .ssh/config,请使用 git clone -o gerrit ssh://<gerritusername>@gerrit.lighttpd.net:29418/lighttpd/lighttpd2.git)

或将远程添加到您现有检出

git remote add gerrit gerrit.lighttpd.net:lighttpd/lighttpd2.git

您还需要 commit-msg hook,您可以通过以下方式获取(在检出目录中)

scp gerrit.lighttpd.net:hooks/commit-msg .git/hooks/
chmod +x .git/hooks/commit-msg

(如果您没有配置 .ssh/config,请使用此命令复制它:scp -p -P 29418 <gerritusername>@gerrit.lighttpd.net:hooks/commit-msg .git/hooks/)

要将更改(GitHub 语言中的“拉取请求”)推送到 Gerrit,您需要推送到 "refs/for/master"(所有工作目前都在 master 分支上完成)。我喜欢使用以下方法来始终推送到此引用

git config --add remote.gerrit.push HEAD:refs/for/master

如果您想在 git remote update 时下载所有更改,也可以添加此项

git config --add remote.gerrit.fetch '+refs/changes/*:refs/remotes/gerrit/changes/*'

上传更改(“拉取请求”)

像往常一样创建您的提交。由于审查是针对每个提交进行的,您应该确保每个提交都能编译并本身就是一个良好的更改。使用 git rebase 来压缩、编辑和重新排序您的提交(git rebase 是高级 Git 用户强大的工具)。

然后只需将其推送到 gerrit refs/for/master,如果您按照上述配置,这应该可以正常工作

git push gerrit

(或者明确指定:git push gerrit HEAD:refs/for/master)

根据审查的反馈,您可以更改您的提交(使用 git rebase 或对于单个提交使用 git commit --amend)并再次上传。您安装的“commit-msg”hook 将为每个提交添加一个 Change-Id,用于跟踪更改。(如果您没有使用 hook,Gerrit 会添加自己的 ID;在这种情况下,您需要从 Gerrit 拉取提交才能修改它。)

stbuehler10 多年前更新 · 3 个版本