Gerrit: Some experience records of stepping on pits during personal use/Change-Id/Cherry-Pick

background description

I just came into contact with gerrit recently, and recorded some personal experience in the process of using it (I have used git, but I don’t know what gerrit is. Click here: The difference between git and gerrit )

踩坑①:missing Change-Id in commit message footer

Refer to the gerrit push configuration , the first git push review reports an error:
missing Changed-Id
prompt "ERROR: commit xxxx: missing Change-Id in message footer"
Execute git log to view the submission record:
The latest commit record is missing the Change-Id
you can see that the latest submission does lack Change-Id, refer to This blog of the gerrit scenario tutorial solves it (if the lack of Change-Id is not the latest submission, please also refer to this blog):
run the two pieces of code in the error message of git push review (the two codes under the two red boxes in the first picture Segment of code), directly select the relevant code on the command line, press "Shift+Insert", and then press Enter to execute: then
Results of the
run git log, you can see that the latest submission has generated a Change-Id~

PS: It is possible to report an error when executing the statement in the first red box:

subsystem request failed on channel 0
scp: Connection closed

Refer to the blog subsystem request failed on channel 0 to solve it, as long as the
“scp -p -P”
replace with
“scp -O -P”
If you execute it again, you will not report an error~

Step on the pit ②: push error after cherryPick

For problem descriptions and solutions, please refer to this blog where gerrit merges branch Cherry-Pick and then push reports an error .
The author's personal understanding may not be professional : gerrit will merge the submission with the same ChangeId into the same remote change. If this remote change is already in the abandon state, it will not be able to receive new submissions and will report an error. So, there are two solutions at this point:

  1. Referring to the above blog, git commit --amend deletes the Change-Id and regenerates a new Change-Id, which is submitted as a new change;
  2. Click restore in gerrit to restore the abandoned changes. At this time, the local can normally submit this change

☆☆☆git/gerrit commits a killer feature☆☆☆

Because the author is not familiar enough with git to submit problems (mostly local messy records), there is a "simple and universal" killer (Tried and tested ★▼★):

0If there are new changes in the remote branch, please git stash to temporarily store the local changes, then git pull to pull the remote latest code, and then git stash pop to restore the local changes (if there is a conflict, please handle it), in short, you must ensure that the local contains the latest remote code (Because this code will be used later to overwrite the code pulled from the remote again)
①Back up the project core files under the project folder to be submitted except for the .git folder and automatic installation/generation (such as the node_modules folder) to another A new folder;
②Delete all files under the project folder to be submitted;
③Re-pull the remote code in the project folder to be submitted;
④Overwrite the project folder to be submitted with the files backed up in the newly created folder Corresponding files (Emm... Let me say one more thing, pay attention to whether the remote has the latest changes at this time);
⑤Clean, no more messy submission problems!

Reference URL

[1] Difference between git and gerrit
[2] gerrit push configuration
[2] gerrit scenario tutorial
[3] gerrit submission lacks Change-Id
[4] push error after gerrit merges branch Cherry-Pick
[5] Understanding gerrit's Change-Id
[6] subsystem request failed on channel 0

Guess you like

Origin blog.csdn.net/qq_36604536/article/details/124928815