Here is the short and quick description of Gerrit key teminology.
Every time you push a commit with a new Change-Id Gerrit allocates a new change. Every change has a unique Change-Id and a Change Number. The change contains a number of patch sets, comments on the patch sets and a code review rating (+2, +1, 0, -1, -2). Each change has a dedicated page that shows information about it called individual change page. This includes dependencies between different changes, patch sets and the review comments.
Once a change has received a +2 in the Code Review and no negative voting in the other categories the last patchset can be submitted. This means Gerrit will now try to cherry-pick your patch set and mark the change as merged.
If you want to modify your change, you don’t have to push a new change to Gerrit but only a new patch set . Imagine a patch sets as different versions or revisions of a change. Each patch set can receive inline comments. Gerrit uses the Change-Id of a commit message to identify patch sets of a change. This is why all patch sets of a change have the same Change-Id.
To create a new Patch when new changes are submitted
Step 1: Install commit-msg hooks for gerrit
[code]$ scp -p -P 29418 localhost:hooks/commit-msg .git/hooks/[/code]
Step 2: Create normal commit and push (for Patchset1)
git add Server.java
git commit -m "server added"
git push origin HEAD:refs/for/master[/code]
Step 3: After doing some changes to Server.java
Finally to create new Patchset (Patchset 2)
[code]git add Server.java
git commit –amend
git push origin HEAD:refs/for/master
Repeat step 3 for further Patches[/code]
Understanding the Patch set in Git perspective
Git is a very advanced distributed source code control system. Maintaining patch sets (often called a topic branch) in Git. Git includes a rebase capability that is very useful for a number of different operations related to maintaining a branch of code including moving a branch forward, moving a branch around on an upstream branch to look for breakage, and merging changesets to create patch files.
Git: How to create and apply patches
Creating a patch
[code]Make your changes and commit them.
Run $ git format-patch COMMIT_REFERENCE #to convert all commits since the referenced commit (not including it) into patch files.
$ git format-patch HEAD~~
This will create 2 files, one for each commit since HEAD~~, like these:
You can use git apply some.patch to have the changes from the .patch file applied to your current working directory. They will be unstaged and need to be committed by you.
[code]To apply a patch as a commit (with its commit message), use git am some.patch. \
For all patches to be applied, simply run:
$ git am *.patch
Note that in some previous version you could pass the latest patch filename of a list of patches to apply all previous patches as wel
$ git am 0002-allow-users-to-be-locked.patch # May no longer work for you[/code]
You then have the 2 unpushed commits from the patch file created earlier.
- How to configure Elastic filebeat 8.3 with Elasticseach? - August 11, 2022
- How to Configure IP Network with ‘nmtui’ Tool - August 11, 2022
- Istio Tutorials: How to install & configure istio?￼ - August 11, 2022