1,Environment preparation
- Install git client on your PC
- config the username and email
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@sap.com"```
* add the id_rsa.pub key to gerrit
* copy the content from file 'C:\Users\iXXXXXX\\.ssh\id_rsa.pub' on your PC ,if there is no this file,please generate one. You can go to https://git.wdf.sap.corp/#/settings/ and click 'SSH Public Keys' to add this key or find more details about how to add a public ssh key to gerrit.
### 2,SAP code review sites
* [SAP gerrit](https://git.wdf.sap.corp)-for the code review
* [SAP projectportal](https://projectportal.neo.ondemand.com)-for projects management
### 3,code review steps
* step 1, get the project repository,where iXXXXXX is your ID number
$ git clone ssh://iXXXXXX@git.wdf.sap.corp:29418/master.git
* step 2, preparation
$ cd master ```
config the origin address
$ git config --local remote.origin.push HEAD:refs/for/master```
master branch setting
$ git config --local branch.master.remote origin
$ git config --local branch.master.rebase true
set git auto generate commit id,where the 'iXXXXXX' is your ID number
$ scp -P 29418 iXXXXXX@git.wdf.sap.corp:hooks/commit-msg .git/hooks/```
show the current branch,usually, you will see 'master' branch only because there is only one branch on gerrit
$ git branch```
suppose there are two code reviews in progress,one local git branch only handle one review .the 'master' branch is default created after we get the git repository,so we need create another branch based on the remote branch to handle another review.
$ git branch develop remotes/origin/master
// create a develop branch
$ git config --local branch.develop.rebase true
$ git config --local branch.develop.remote origin
//develop branch setting```
usually, we should keep the local code up-to-date before we start to submit a review.
//$ git checkout master
//or
//$ git checkout develop
$ git pull
//or use 'git fetch' or ' git remote update'```
* step3, code changes and submit code reviews, suppose we have two code reviews. the one is on master branch,another one in on the develop branch.
/**
* we start to use master branch to submit one code review
/
$ git checkout master
$ git pull
$ echo first review and first change >> readme.txt
$ git add readme.txt
$ git commit -m 'my first code review' //first commit should use this command and will generate a new code review
$ git push origin //push the last commit to gerrit review
$ echo first review and second change >>readme.txt //if review fail, we may need enhance our code
$ git add readme.txt
$ git commit --amend //use amend commit to put a review patch and will not generate a new review package
$ git push origin
$ echo first review and third change >> readme.txt
$ git add readme.txt
$ git commit --amend
/*
* we start to use develop branch to submit another code review
*/
$ git checkout develop
$ git pull
$ echo second review and first change >> mmm.txt
$ git add mmm.txt
$ git commit -m 'my second code review'
$ echo second review and second change >> mmm.txt
$ git push origin```
- step 4, your colleagues will help to finish this code review on gerrit