The first time I came into contact with gerrit, I would be very repelled by this code management method, especially those who are used to using sourceTree with git for code management. If you are unhappy, you will have to write the code. Our goal is to make the development process cool.
About the knowledge of gerrit, move here to learn: [Gerrit] Gerrit Workflow and User Manual
Unfamiliar students can continue to study after reading the above article.
The main problems we encountered are as follows:
1 Before pulling the code for the first time, you need to configure the local git environment
1 Some functions of sourceTree can not be used, which makes people uncomfortable. For example, you cannot push directly
2 In the process of submitting code, if there is a conflict, gerrit does not give merge permission by default. How to deal with it?
First, the first git configuration
1 Set Git username and email
$git config --global user.name tao.wang $git config --global user.email [email protected]
2 Verify
$git config --global user.name // tao.wang
$git config --global user.email [email protected] // [email protected]
3 Create SSH Key public and private keys and upload gerrit. This step is familiar to everyone. Don't know google.
4 Configure local gerrit
Create a config file in the previously created .ssh folder (or copy the configured config file directly), the content of the config file (note that the user name is replaced with your own account name, the port port defaults to 29418, some companies will change it, pay attention to replace available ports):
host gitserver hostname 172.16.99.xx user tao.wang port 29418 host gerrit hostname 172.16.99.xx user tao.wang port 29418 KexAlgorithms +diffie-hellman-group1-sha1
git push origin master
Why is this? If you have read the article [Gerrit] Gerrit Workflow and User Manual , you will know that gerrit has added a codereview process. So it will depend on a temporary branch, and we need to submit the code to this temporary branch.
So, pull the code with the following command:
git push origin HEAD:refs/for/master
git config remote.origin.push refs/heads/*:refs/for/*
Modify the config file, invalid!
The second is to create a custom action, execute the script, and the script pushes correctly. Facts have proved useful!
1 Use xcode to create a shell script with the following content
#!/bin/sh # push.sh #KeepRunning # # Created by Wang Tao on 2018/4/27 . # Copyright © 2018年 niujinfeng. All rights reserved. # Get the current branch name branch=`git symbolic-ref --short -q HEAD` # push review git push origin HEAD:refs/for/${branch}
2 Create a custom operation in sourceTree, the configuration is as follows, the parameter column is the path where the script is located, please replace the correct path