Gerrit 使用

参考Gerrit的使用说明 
ssh -p 29418 hwh@188.188.1.9 gerrit --help
可以查看每一个命令的说明:比如create-project 
ssh -p 29418   hwh@188.188.1.9 gerrit create-project --help 

1.创建项目(必须要有管理员权限) 
ssh -p 29418   hwh@188.188.1.9 gerrit create-project -p All-Projects -n Art --empty-commit 
可以在本机上使用:  29418 gerrit服务器端口,hwh是gerrit账号,  188.188.1.9 服务器地址  
gerrit create-project 用gerrit来创建项目 -p All-Projects 权限从All-Projects继承 p是父项目 
-n Art project名字是Art --empty-commit 项目创建时,加一个空提交。
2.删除gerrit用户 
ssh -p 29418   zbb@review.mdaxue.com gerrit gsql 
delete from ACCOUNT_EXTERNAL_IDS where external_id='username:zzy'; 
3、从git服务器获取代码 
git clone   http://188.188.1.9/Art
git clone ssh://hwh@188.188.1.9:29418/Art 
4.创建http登录帐号 
htpasswd -b ./review_site/etc/passwd hwh 123456 
更新账户,htpasswd -b ./review_site/etc/passwd hwh 12345678
5.管理员创建邮箱 
回到本机通过ssh远程连接创建邮箱 
$ cat ~/.ssh/config  
 Host ha 
     HostName 192.168.1.99 
     User root 
     Port 29418 
     IdentityFile ~/.ssh/id_rsa 

 $ ssh ha gerrit set-account --add-email accountemail accountname 

6、删除项目 
到gerrit服务器里,直接删除该项目比如:test.git 
重启gerrit服务器,进去看list,发现这个项目没有了。 

7、push代码和tags 
 git push --tags origin HEAD:refs/heads/qmc-8974-la-4.0.2-ref 
把从高通下载的代码和tag一起push到服务器,结果是代码可以push,tag不能。 

自己新建一个git,加上代码和tag,push的服务器,结果是可以push。 

查找权限,refs/heads/*已经有权限了,可以push code,所以我们要查找tag的权限,refs/tags/*的权限也都有了。所以我们自己的git可以push code和代码,但是为什么别人的code不能push tag呢?需要加Forge Author Identity和Forge Committer Identity 



Forge Author 
Normally Gerrit requires the author and the committer identity lines in a Git commit object (or tagger line in an annotated tag) to match one of the registered email addresses of the uploading user. This permission allows users to bypass parts of that validation, which may be necessary when mirroring changes from an upstream project. 

Permits the use of an unverified author line in commit objects. This can be useful when applying patches received by email from 3rd parties, when cherry-picking changes written by others across branches, or when amending someone else’s commit to fix up a minor problem before submitting. 

By default this is granted to Registered Users in all projects, but a site administrator may disable it if verified authorship is required. 

Forge Committer 
Normally Gerrit requires the author and the committer identity lines in a Git commit object (or tagger line in an annotated tag) to match one of the registered email addresses of the uploading user. This permission allows users to bypass parts of that validation, which may be necessary when mirroring changes from an upstream project. 

Allows the use of an unverified committer line in commit objects, or an unverified tagger line in annotated tag objects. Typically this is only required when mirroring commits from an upstream project repository. 

Forge Server 
Normally Gerrit requires the author and the committer identity lines in a Git commit object (or tagger line in an annotated tag) to match one of the registered email addresses of the uploading user. This permission allows users to bypass parts of that validation, which may be necessary when mirroring changes from an upstream project. 

Allows the use of the server’s own name and email on the committer line of a new commit object. This should only be necessary when force pushing a commit history which has been rewritten by git filter-branch and that contains merge commits previously created by this Gerrit Code Review server. 

<think>嗯,用户想了解Gerrit使用方法和配置指南。首先,我需要回忆一下Gerrit的基本概念。Gerrit是一个基于Git的代码审查工具,常用于团队协作开发,特别是在开源项目中。它的核心功能是代码审查和权限管理,所以用户可能是在团队中负责代码审核或者需要搭建代码审查流程的人。 接下来,用户的问题包括使用教程和配置指南,我需要分两部分来回答。使用教程部分应该包括安装、基本配置、代码审查流程等。配置指南可能涉及权限设置、插件安装、与CI/CD集成等。需要注意用户可能是新手,所以步骤要详细,避免使用过于专业的术语,或者如果用到术语,应该适当解释。 系统级指令要求使用中文回答,数学公式用$...$或$$...$$,但Gerrit相关的内容可能不涉及数学公式,这部分可能不需要特别处理。不过要确保LaTeX语法正确,如果有的话。另外需要生成相关问题,可能的问题包括权限管理、与GitLab集成、常见错误解决等。 用户提供的示例是关于快速排序的,回答结构清晰,有代码示例和相关问题。我需要模仿这个结构,但针对Gerrit。可能需要分步骤讲解安装、配置、使用流程,然后代码示例可能是配置文件或命令行的例子,比如git push到Gerrit的命令。 另外,引用标识需要自然添加,可能引用Gerrit官方文档或者其他可靠来源。例如,在讲解安装步骤时,可以引用官方安装指南作为参考。 需要检查Gerrit的最新版本是否有变化,确保提供的信息不过时。例如,安装方法是否有新的依赖,或者配置文件的路径是否有改动。如果用户的环境不同(比如Windows或Linux),是否需要分别说明?可能需要提到不同系统的差异,但保持简洁。 权限配置部分比较复杂,可能需要详细说明如何通过Gerrit的配置文件或Web界面设置权限。例如,如何创建项目,设置分支权限,添加用户组等。这部分容易出错,用户可能会遇到问题,所以步骤要清晰。 代码审查流程的步骤包括提交代码、创建评审、评审通过后合并等。需要解释每个步骤的具体操作,比如使用git push到refs/for/branch名称,以及如何通过Web界面进行评审。 生成的相关问题可能包括如何集成Gerrit与Jenkins,如何处理合并冲突,如何备份Gerrit数据等。需要确保问题覆盖用户可能遇到的后续疑问。 最后,确保回答结构符合要求:分点说明使用教程和配置指南,代码块用正确的语法,引用标识自然,然后列出相关问题。避免使用Markdown格式,但用户提供的示例中代码块用了```python,这里应该用```bash或其他合适的语言,比如git命令或配置文件内容。 总结一下,我需要组织Gerrit使用教程和配置指南,分步骤详细说明,提供必要的命令和配置示例,添加引用,最后生成相关问题。需要确认所有信息准确,符合当前最佳实践,并且易于理解。</think>### Gerrit 使用与配置指南 Gerrit 是一个基于 Git 的代码审查工具,支持团队协作开发与代码质量管理[^1]。以下是其核心使用方法和配置步骤: --- #### **一、Gerrit 基础使用教程** 1. **安装与初始化** - 下载 Gerrit:从[官方网站](https://www.gerritcodereview.com/)获取最新版本。 - 初始化仓库: ```bash java -jar gerrit.war init -d /path/to/gerrit_site ``` 按提示完成数据库(如 H2 或 PostgreSQL)和认证方式(如 LDAP 或 OpenID)配置[^2]。 2. **代码提交与审查流程** - 提交代码至 Gerrit: ```bash git push origin HEAD:refs/for/<branch-name> ``` -Gerrit Web 界面查看提交,进行代码评审(+1/-1 评分)或合并(+2 权限)。 3. **评审规则配置** - 通过 `project.config` 文件定义代码合并条件,例如: ``` [submit] action = fast_forward_only [label "Code-Review"] function = MaxWithBlock value = -1 0 +1 +2 ``` --- #### **二、Gerrit 高级配置指南** 1. **权限管理** - 在 `All-Projects` 仓库的 `refs/meta/config` 分支中,修改 `groups` 文件添加用户组,并在 `project.config` 中分配权限: ``` [access "refs/*"] owner = group Project-Admins read = group Developers ``` 2. **集成 CI/CD** - 通过 Gerrit 触发器与 Jenkins 或 GitLab CI 联动,例如监听 `refs/changes/*` 触发自动化测试[^3]。 3. **插件扩展** - 安装插件(如 `webhooks` 或 `oauth`): ```bash java -jar gerrit.war init -d /path/to/gerrit_site --install-plugin=webhooks ``` --- #### **三、常见问题示例** 1. **如何解决 `missing Change-Id` 错误?** 在本地 Git 仓库安装 commit-msg 钩子: ```bash scp -p -P 29418 <gerrit-server>:hooks/commit-msg .git/hooks/ ``` 2. **如何备份 Gerrit 数据?** 使用 `gerrit backup` 命令或直接备份 `gerrit_site` 目录。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值