安裝git-reviewgit
# yum install git-review # centos7上epel源上有git-review rpm包 # pip install git-review # pip源安裝亦可
一、第一次提交
centos
# git clone 遠程倉庫 # git config --global user.email "yao.xxxxx@xxxxx.net" # git config --global user.name "xxxxxxx" # 配置全局的用戶名 # git config --global --add gitreview.username "xxxxxxxx" # 配置gitreview用戶名 # git remote add gerrit ssh://xxxxxx@review.sh.xxx.net:29418/xxxcloud/openstack-deploy.git # 代碼走review過程 # git remote add gerrit https://<<https認證用戶>>:<<https認證密碼>>@review.sh.xxx.net/xxxcloud/openstack-deploy.git # 在國內29418端口被牆了,你能夠選擇https的方式 #也能夠經過這種方式保存用戶名/密碼 # echo "[credential]" >> .git/config # echo " helper = store" >> .git/config # git checkout -b 新分支 (分支命名:跟你提交的功能相關) # git add . # git commit # 填寫提交信息 # git review -v # -v顯示詳細信息
二、已經提交過,針對上一次提交的patchbash
# git fetch ssh://xxxxxx@xxxxxx:29418/99cloud/openstack-deploy refs/changes/13/13/1 && git checkout FETCH_HEAD # git fetch下遠程的patch分支 # git checkout -b 新分支 (分支命名:跟你提交的功能相關) # git add . # git commit --amend # 使用一樣的change id # git review -v(出現衝突,須要git rebase)
三、針對遠程feature開發分支的bug修復ssh
# git branch -a # 基於master分支有個cr-dev分支 * master remotes/origin/HEAD -> origin/master remotes/origin/cr-dev remotes/origin/master # git checkout --track origin/cr-dev # --track 能夠讓本地分支cr-dev和遠程分支cr-dev作upstream Branch cr-dev set up to track remote branch cr-dev from origin. Switched to a new branch 'cr-dev' # git branch -a * cr-dev master remotes/origin/HEAD -> origin/master remotes/origin/cr-dev remotes/origin/master # git checkout -b fix_haproxy_influxdb # 基於本地cr-dev分支,建立一個新的branch出來做爲review的topic # git branch -a cr-dev * fix_haproxy_influxdb master remotes/origin/HEAD -> origin/master remotes/origin/cr-dev remotes/origin/master # 在你提交以前,遠程分支cr-dev上已經有幾個commit了,這時候須要git rebase # git checkout cr-dev # 切換到cr-dev # git branch -a * cr-dev fix_haproxy_influxdb master remotes/origin/HEAD -> origin/master remotes/origin/cr-dev remotes/origin/master # git fetch origin # 這裏不用git pull,git pull至關於git fetch && git merge過程 # git merge origin/cr-dev # 和遠程的cr-dev分支合併 # git checkout fix_haproxy_influxdb # 切換到fix_haproxy_influxdb分支 Switched to branch 'fix_haproxy_influxdb' # git rebase -i cr-dev # 會將cr-dev分支的代碼合併過來,並按照提交的順序排序 # git add * # git commit # git review # 若是gerrit code reivew merge的時候遇到以下錯誤,如何解決? The change could not be merged due to a path conflict. Please rebase the change locally and upload the rebased commit for review. 解決: git checkout master git pull --rebase git checkout bug/1485710(舉例bug分支) git rebase -i master 有衝突,手動解決 git add . git commit --amend git review # git生成patch # git format-patch 前commit-id 後commit-id(不寫,默認最後一個commit-id) # 如何解決gerrit和gitlab數據不一致 找出gerrit數據目錄 GerritCodeReview -jar /etc/review_site/bin/gerrit.war daemon -d /etc/review_site --run-id=1445571445.29699 /etc/review_site gerrit數據目錄 # ll /etc/review_site/git/openstack/ total 0 drwxr-xr-x 7 root root 129 Nov 3 11:39 cinder.git 刪除cinder.git # cd /etc/review_site/git/openstack/ # rm cinder.git # git clone --bare git@172.16.102.51:openstack/cinder.git # 加上--bare選項