Background
I am using Gerrit. One commit C
has been merged into branch dev
and needed to be cherry-picked into branch main
. One of my colleagues have tried to cherry pick using below command.
git checkout main
git cherry-pick `C`
He pushed in Gerrit and after some review he messed up and end up abandoning the commit C
on branch main
. Now, when I am trying freshly to cherry pick the same commit. Gerrit is rejecting the commit to push on branch main
, saying that the commit is already closed. As a policy we can not push as new commit rather we must cherry pick for keeping branch histories.
To ssh://gerrit.company.net:29417/project
! [remote rejected] HEAD -> refs/for/main (change https://gerrit.company.net/open/426535 closed)
error: failed to push some refs to 'ssh://[email protected]:29417/project'
How can I deal with this situation?
You could try to change the Change-Id of your change:
Amend your local commit (commit --amend)
Remove the Change-Id and save
Push again to Gerrit