If you want to submit changes directly without code review, especially when
- Import existing repositories, SDK, or other original opensource packages that does not need code review
- "git review" command fails due to remote branch does not exist
You can use commands as below instead to bypass code review process.
- Add "gerrit" remote if it does not exist, skip this if you have "gerrit" remote.
git remote add gerrit ssh://<username>@<gerrit_server>:29418/<project_name>.git
- Push your changes to Gerrit directly without code review.
git push gerrit "[branch_name](eg HEAD:ref/for/master)"
eg:
-
查看 project name # git config -l (这里就是 prpos-v3.2.0)

-
git remote -v 查看 remote 的 gerrit 仓库名 没有添加
git remote add gerrit ssh://<username>@<gerrit_server>:29418/<project_name>.git
- 推送本地到gerrit
git push gerrit HEAD:refs/heads/master // HEAD 本地最新
eg:git push gerrit HEAD:refs/for/master // 推送最新一笔code 到gerrit review
- Step 3 可能会失败
获取Git仓库目录
- gitdir=$(git rev-parse --git-dir) // 这里其实就是 .git 目录
从Gerrit服务器下载commit-msg钩 子并安装
- scp -p -P 29418 adley_cheng@172.21.67.99:hooks/commit-msg ${gitdir}/hooks/
eg: scp -p -P 29418 adley_cheng@172.21.67.99:hooks/commit-msg .git/hooks/
-
git commit --amend --no-edit
-
git push gerrit HEAD:refs/for/master // 再推送
一般需要gerrit review 才上code ,不要轻易 git push