Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"un-committing" a file from a pushed changeset in gerrit

Tags:

git

gerrit

I have a commit with two files changed (file a and b), I pushed it to gerrit repo (but not yet merged). Now I realize I dont need to update b. How do I push a new changeset that removes/un-commits b and only includes file a?

like image 261
Ron Avatar asked Sep 21 '25 04:09

Ron


1 Answers

In your your local repository do the following:

  1. Remove file-b from the commit

    git reset HEAD^ -- file-b
    
  2. Amend the commit without the file-b

    git commit --amend
    
  3. Discard file-b changes

    git checkout -- file-b
    
  4. Confirm that everything is OK

    git status
    git log
    git diff HEAD^ HEAD
    
  5. Push the new commit to Gerrit (new patchset)

    git push origin HEAD:refs/for/master
    
like image 109
Marcelo Ávila de Oliveira Avatar answered Sep 23 '25 08:09

Marcelo Ávila de Oliveira