Git: Pushing remote branch to Gerrit

If you use the Gerrit as your code review tool, then follow the below steps for pushing the remote branch to Gerrit.


1. Create a local branch to track for the Remote Branch. Run the below command for the same. 

 git branch LOCAL_BRANCH_NAME origin/REMOTE_BRANCH_NAME 

2. Then try to merge your local branch with master branch to avoid any conflicts. This will be helpful when we merge the master with REMOTE_BRANCH_NAME in the future.

 git merge origin/master 

3. Make the necessary changes in the code and run the below commands to add and commit it. 

 git add . 
 git commit -m "COMMIT_MESSAGE" 

4. Run the below command to push the code to gerrit for the remote branch 

git push gerrit LOCAL_BRANCH_NAME:refs/for/REMOTE_BRANCH_NAME 

Advertisements