gitgerritgit-refspec

Error pulling refs/notes/review from gerrit (non-fast-forward)


git pull request is failing each time because a change in refs/notes/review in the remote gerrit instance cannot be fast forwarded. I did (hard) reset the local branch to be in sync with the remote branch but that doesn't help with this (git reset --hard origin/master).

$ git pull
From https://gerrit.***.com/a/***
 ! [rejected]                refs/notes/review -> refs/notes/review  (non-fast-forward)

$ git show-ref refs/notes/review
7a54cf8a28a1d9e1dd106950a49b2a962c2af0e4 refs/notes/review

$ git fetch origin
From https://gerrit.***.com/a/***
 ! [rejected]                refs/notes/review -> refs/notes/review  (non-fast-forward)

The remote gerrit instance was restored to a backup point and is behind the local branch. We brought the remote branch to the current state by pushing back everything from the local branches. However, it appears that some of the review notes are missing in the remote branch.

I came across git-update-ref but I don't know how to get the commit id to use here. Should I just use the commit id of the latest commit in the remote branch? I could, of course, do trial and error but really don't want to mess up the repository state and have to clone it again.

Any hint or pointer will be appreciated.


Solution

  • It is a note (refs/notes/... reference), not a branch (refs/heads/...).

    Look at where is your local note, and the remote note : if your local note seems to be a sensible evolution, push it.

    If you want to force your local ref to the value of the remote, you can force fetch that reference only :

    git fetch --force origin refs/notes/review:refs/notes/review