1

I'm new to Gerrit and I think I'm lost not seeing something probably very obvious.

After git status I'm getting:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#   (use "git push" to publish your local commits)

So, I'm doing as instructed, and after git push origin HEAD:refs/for/master I'm getting:

remote: Processing changes: refs: 1, done
To ssh://URL:29418/PROJECT
 ! [remote rejected] HEAD -> refs/for/master (no new changes)

(git push and git push origin brings the very same result -- no new changes)

What am I missing? How can Gerrit claim that repo is ahead remote and that there no new changes in the same time?

BTW: I have no open changes in Gerrit, all of them are either merged or abandoned -- I'm talking about already reviewed and submitted patch/change. See my another question, which is related to this one.

Community
  • 1
  • 1
trejder
  • 17,148
  • 27
  • 124
  • 216

1 Answers1

1

Till the change is not submitted from review branch to remote branch the remote branch will be behind to the local branch. But if the change/patchset does not modified it can not be pushed again to review branch. So first organize a review for your change and submit it in successful case.

Edit: refresh the remote branch info by git fetch. And I suggest that always check the remote repo status by using git remote show <remote_name> - with this you can query all the branches and you could see which one is out of date - I think the that is the situation now

Edit2: if you use git fetch then also update the local branch with git merge origin/<branch> or use git pull which is actually the two commands in one. Or If you sure that all the changes has been merged to remote branch you can reset the local branch as well - git reset --hard origin/<branch>

Edit3: when you make a direct push the local info will be updated automatically since the local branch and remote branch are synchronized. But when you push to a review branch git does not know about the life of that change further more. So till the local branch not updated with the remote branch git assumes that the local is ahead of the remote. so git pull or git fetch; git reset --hard origin/master should fix this.

laplasz
  • 3,359
  • 1
  • 29
  • 40
  • I don't have any open changes in my Gerrit, which means that this particular (and all other) changes has already been reviewed (actually by me) and submitted. It now has `Status: merged`. We're talking about _reviewed and submitted_ change ([related question](http://stackoverflow.com/q/20607231/1469208)). – trejder Dec 16 '13 at 11:12
  • The `git fetch` didn't change anything. However, `git remote show origin` showed me that my `HEAD` is ambiguous and listed one of previous changes (not the latest one) next to `master` on `maybe on of the following` list. Mentioned (ambiguous?) branch has status `merged` since two days and has already been merged locally (by me, because [Gerrit failed to merge it, though it claims, it did so](http://stackoverflow.com/q/20607231/1469208)). Can this be responsible for situation mentioned in my question? – trejder Dec 16 '13 at 11:29
  • No, I'm always using `git pull`. I know, that it is `git fetch` + `git merge`. I only don't know / don't understand, why after `git pull` my master remains unchanged and latest change / branch that just got `Status: Merged` in Gerrit's UI isn't actually merged to master, as it should be? I would rather not touching anything even close to `git reset` (especially with `--hard` and especially, when dealing with Gerrit)! I'm to fresh / newbie to Git & Gerrit! If there isn't any other way, I'll be merging branches locally manually, if Gerrit can't do this for me. – trejder Dec 16 '13 at 12:13
  • 1
    when a change is pushed to gerrit - all the local changes can be reseted. Since every change can be fetch as it is described [here](http://stackoverflow.com/a/19778924/1342413) – laplasz Dec 16 '13 at 13:10
  • I got your point. But it still doesn't explain, why Gerrit marks a change as _merged_, but doesn't actually merge branch connected to that change, to master branch? – trejder Dec 16 '13 at 13:40
  • 1
    in your example you pushed to master review branch so when the change submitted/merged then the change will be appear in remote master branch - so it can be pulled for everyone – laplasz Dec 16 '13 at 14:02