15

I am new to Gerrit and want to create a new Patch when new changes are submitted. I setup Gerrit with this guide https://review.typo3.org/Documentation/install-quick.html

Then I try to create a new patch with http://gerrit.googlecode.com/svn/documentation/2.0/user-changeid.html and also added Change-Id line at bottom of the Commit-message.

But I am getting new Change instead of new Patchset. Can anyone help me?

Thanks

Gangaraju
  • 4,406
  • 9
  • 45
  • 77

3 Answers3

31

Step 1: Install commit-msg hooks for gerrit

scp -p -P 29418 <gerrit_url>:hooks/commit-msg .git/hooks/

Step 2: Create normal commit and push (for Patchset1)

for example:

git add Server.java
git commit -m "server added"
git push origin HEAD:refs/for/master

Step 3: After doing some changes to Server.java

Finally to create new Patchset (Patchset 2)

git add Server.java
git commit --amend
git push origin HEAD:refs/for/master

Repeat step 3 for further Patches

Gangaraju
  • 4,406
  • 9
  • 45
  • 77
  • 6
    A note for anyone else potentially confused - this literally means you should push to `refs/for/master`. That isn't a placeholder for some remote branch name you have to figure out - it's actually the remote branch name gerrit expects – Hamy Jul 31 '15 at 03:35
  • 1
    Shouldn't you install the `commit-msg` hook *first*? With these steps,the initial commit pushed to gerrit won't have a change-id. – larsks Apr 20 '16 at 13:31
  • Is there any way to do same thing in GitHub? – Md. Ikramul Murad Feb 01 '20 at 17:23
  • 1
    AFAIK, GitHub uses different code review approach. Just push using normal commands and create a pull request. So you don't need to set up anything extra. – Gangaraju Feb 03 '20 at 05:20
4

Don't add the Change-Id on your own. Install the commit-msg hook as described here. This will automatically create the Change-Id for you.

If you want to improve a patch by uploading a new patch-set, use git-commit --amend and keep the Change-Id line as it is.

You can see a description of the workflow here: http://wiki.typo3.org/Contribution_Walkthrough_with_CommandLine

StephenKing
  • 36,187
  • 11
  • 83
  • 112
2

Even if you add Change id manually it should be last paragraph of your commit message.
And the syntax should be :

change ID : [change ID ]
John Moutafis
  • 22,254
  • 11
  • 68
  • 112
mrutyunjay
  • 6,850
  • 7
  • 25
  • 35