Search code examples
gitgerrit

Git pushes to wrong gerrit change


I tried to push to gerrit after my new commit but I get this error: ! [remote rejected] HEAD -> refs/for/master (change (here is my change link) closed) error: failed to push some refs to 'link to my repo'

The change link is the change I made before on this repo, but has completely different change ID then my current commit, I tried switching branches, rebasing, pulling changes etc. Everything is up to date but if I push it only wants to push to my last closed commit instead of creating a new change in gerrit

Did someone had a similar problem? I only noticed a post where someone had the same ID on his new commit but I have different change ids


Solution

  • Ok, I found the issue and resolved it.

    I don't really understand how it works, but my last commit I had (on completely different branch) for some reason stayed after being pushed? Meaning that it still had some changes to be pushed even though it had none. And when I was finished working on my other branch with my other commit, when trying to push to gerrit, git wanted to push both of those commits, even though the last one shouldn't be pushed at all because it had no changes to push and was on a different branch... Perhaps some bug from gerrit.

    But anyway, I used git rebase -i and just deleted the line with the buggy commit Everything works correctly now.