使用gerrit進行code review

2021-07-02 14:01:59 字數 1216 閱讀 7993

gerrit系統提供了**review的機制。要使用其**review的功能,需要進行一些配置,新增一些相關的工具,並設定review人等相關資訊。具體步驟如下:

scp -p -p 29418 [user]@sina.git.intra.sina.com.cn:hooks/commit-msg .git/hooks/
上述命令的「[user]」替換為自己的gerrit賬號,即郵箱字首。

git commit提交到本地庫

首先,使用下面這個命令來設定git預設的編輯器,其中的「editor」替換成你自己的編輯器,如vim、emacs、gedit、subl等:

git config --global core.editor "editor -w"

然後,在做提交的時候使用命令不要寫"-m"引數,直接寫成git commit這樣子就行,這樣就會自動開啟你剛才指定的編輯器,你可以在裡面新增大段注釋。

2.修改config檔案

進入當前git倉庫的.git目錄下,能看到乙個config檔案。用文字編輯器開啟此檔案,檢視檔案中是否存在「[remote "review"]」相關的設定,如不存在,則在檔案末尾新增如下內容:

[remote "review"]

pushurl = ssh://[user]@xx.xx.xx.xx/[repository]

push = head:refs/for/[branch]

receivepack = git receive-pack --reviewer [reviewer]

其中,「[user]」替換為自己的gerrit賬號,「[repository]」替換為當前倉庫在gerrit上的路徑,「[branch]」替換為**所提交的分支,「[reviewer]」替換為自己的review人的gerrit賬號(必須為gerrit存在的賬號,否則無法正常push**)。示例:

[remote "review"]

pushurl = ssh:

push = head:refs/for/development

receivepack = git receive-pack --reviewer user

3.push**

完成上述配置之後,就能進行**review了。當你需要把本地**push到伺服器時,不能直接git push,而應當執行如下命令:

git push review
4. 這樣gerrit會跟你傳送郵件,然後進行**的review工作。

gerrit使用注意

1 在 git clone 時需要注意將commit msg hook也 copy 下來,例如 git clone ssh scp p p 8090 zhoumin abc.cn hooks commit msg def git hooks 2 在提交之前需要檢查以下三項是否正確,包括author ...

關於Git及Gerrit的使用詳細網頁參考

1.git就是乙個版本管理庫,在git庫中沒有中心伺服器的概念,大家都是平等的,真正的分布式。大家可以互相pull push 非常方便。對於做定製很多的公司,其實挺好。2.repo,repo就是多個git庫的管理工具。如果你只是改乙個模組,git夠用了,如果是多個git庫同時管理,最好搞乙個repo...

使用with進行回溯

with dept deptid,pdeptid as select udepid,uparentid from oa.dbo.depinfo where udepid in select p.udepid from oa.dbo.postinfo as p inner join oa.dbo.us...