Undo merge/reset change status

I made a fatal mistake using Gerrit and was wondering if anybody could provide a solution/idea to this:

Current situation is that I have a branch feature-foo onto which our team is pushing changes for review.
Some of these changes are already submitted/merged, and a great number is still open for review.
Now, yesterday I decided to push a patchset to a specific change, one that has around 15 preceeding changes (not merged yet).

  • Retaining Git Commit History in commit message when Merging branches in Git
  • Update patchset
  • GitLab server Repository movement to Git/Gerrit Server
  • How to merge the gerrit branch to another gerrit branch
  • Gerrit: Merged, Outdated
  • change-merged gerrit hook
  • I accidentally pushed past code review (yes, I do have these permissions, and yes I was stupid enough to not deactivate them for my own safety – lesson learned).
    This resulted in those 15 changes/commits to be pushed directly onto the branch instead of into code review.
    So now all those changes are marked MERGED in Gerrit. My immediate idea was to do a push -f using the commit that I knew was originally the tip of feature-foo.

    This correctly reset the branch to where it was supposed to be. But – those 15 changes are still marked MERGED in Gerrit.
    What I want: I need those changes to be back to state “Review in Progress”, because they are in fact still being worked on.

    Any ideas, anybody? I cannot imagine that this has not happened to somebody before…



    EDIT 1: To clarify – the incorrectly pushed commit resulted in a fast-forward – not a merge. Nevertheless, for Gerrit those changes/commits are still “MERGED”, as if somebody pressed “Submit Change” in the Gerrit-Webinterface.
    So – this question is in fact about Gerrit, not Git itself.

    keywords: accidental push, accidental merge

  • Private Repositories not found in SmartGit
  • How do I work on my Rails app in development mode, but push it in production mode?
  • git: 2 developers worked on master branch :(
  • Git repository lost its remote branches?
  • Git commands to switch to an arbitrary git repository/branch?
  • Stuck at push, nothing happens
  • 2 Solutions collect form web for “Undo merge/reset change status”

    The only way I know is to push it again, using a new Change-Id. This results in a new change being opened.

    Well, it turns out that this did the trick:

    1. Reset the branch to where it is supposed to be (force push past code review)
    2. Power down Gerrit, access the underlying H2 database and reset the Status of all affected Change-IDs to “Review in Progress” (standard SQL, use project name, branch name and Change-ID in the WHERE-Clause).
    Git Baby is a git and github fan, let's start git clone.