3

Suppose i have three files - file 1,file 2 and file 3. I add them, commit and push it. It goes to the gerrit system,and suppose i find that i had to change something in the file 1 I abandon the patch in gerrit. In my local system I edit the file 1 and do git status then it will only show file 1 as modified.

My problem here is to push the modified file(file 1 in this case), file 2 and file 3 in a single patch and push it.

If I do git pull it will say already up to date.

I tried git reset <previous commit id> then add my changes and push it. which would work fine but I don't know if its the right method. Can anyone help??

4

2 回答 2

3

Why did you abandon the change?

Gerrit was specifically designed for this purpose that you review your changes, see that file 1 needs to be changed, then you modify your file 1 and submit this again as patch 2

It is correct that the git status shows that only file 1 has changed. It compares to you local repository, not to gerrit.

The right way to do this is to make sure you have the commit-msg hook for gerrit in your local git repository hooks folder. This will add a Change-Id to your commit messages. With this gerrit can track which commits are related to the same change.

  1. Initial change, commit files 1-3: git commit -a
  2. Push to gerrit: git push origin HEAD:refs/for/master
  3. Modify file 1
  4. Amend your last commit to update file 1: git commit -a --amend
  5. Push again to gerrit: git push origin HEAD:refs/for/master

Now your modification will show up as patch 2 and you repeat steps 3-5 until you are satisfied.

于 2013-06-19T01:02:12.777 回答
0

No need to abandon the change.

What are the changes you need, you can do it and follow the below steps.

  • Note : Make sure that git log was showing your most recent commit or not.
  1. git status - it will show the modified files.
  2. git add . or git add modified_file_names
  3. git commit --amend (to make modifications to the most recent commit)
  4. git push origin HEAD:refs/changes/change_id
    Ex: git push origin HEAD:refs/changes/1125642 (This will submit again as next

patch set.)

于 2018-07-17T07:30:33.210 回答