Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to commit the files which were pushed before and abandoned in gerrit

Tags:

git

gerrit

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??

like image 380
Sagar Sakre Avatar asked Nov 18 '25 17:11

Sagar Sakre


1 Answers

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.

like image 125
uncletall Avatar answered Nov 21 '25 06:11

uncletall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!