1

I already ask a question but I have not found the suitable answer yet.

How to a huge code to small patches in Gerrit

For example, my code has several python file: p1.py, p2.py,..., p5.py.

Now I want to group (p1.py and p2.py) in one patchset and group (p3.py. p4.py and p5.py) in another patchset. But the condition is that 2 groups should be the same branch name. Here is an example:

An example shows different patchsets with the same branch name

Please let me know how I can do like this.

Community
  • 1
  • 1

1 Answers1

1

First you have to make git add p1.py and git add p2.py then git commit -m "<message>" and push it to your branch and you will have Change-Id. After push add the other files (p3.py, p4.py, p5.py), edit commit message with git commit --amend command. Now you can make git push and you will have new patch set. Change Id will remain in the commit message. But in case you want to be sure, use amend with --no-edit to disable modifying the commit message.

brainray
  • 12,512
  • 11
  • 67
  • 116
  • Big thanks.. I am still waiting for this answer for a long time. – Shayne Jonas Sep 01 '16 at 08:11
  • Hi @Kaloyan, I just wonder whether we have any way to create several CHANGES with the same branch name as shown in the above example. It means that (p1.py and p2.py) will be submitted to one change and (p2.py, p3.py and p5.py) will be submitted to another change. – Shayne Jonas Sep 01 '16 at 14:14
  • 1
    @ShayneJonas yes you can, one commit means one change in gerrit. So after the first commit you can reset your local branch - to avoid dependency - and commit other files and push as a new change in gerrit – laplasz Sep 01 '16 at 17:12
  • Hi HiB, but in my understanding once we reset the local branch so how I can update the first change (with command git commit --amend). I wonder whether the first commit will be kept, right? Sorry, I am new to git and gerrit. – Shayne Jonas Sep 01 '16 at 17:52
  • @ShayneJonas once a commit uploaded to gerrit, then you can always download it later for modification. The download link is provided in the Gerrit page - http://stackoverflow.com/a/28447617/1342413 – laplasz Sep 02 '16 at 12:33
  • Ah... I know that way but it looks a little bit inconvenient. Anyway, thank you very much. – Shayne Jonas Sep 02 '16 at 17:38