Gerrit doesn't accept newly created change/branch

醉酒当歌 提交于 2019-12-11 23:23:09

问题


I have just created a new change, that I wish to pull to Gerrit. I did it (I hope) the usual way, i.e. create new branch, do magic, commit. Now, I want to push changes to Gerrit. So...

git checkout 82-changes-and-fixes-to-files-view
git push origin HEAD:refs/for/82-changes-and-fixes-to-files-view

(crunch, crunch)

! [remote rejected] HEAD -> refs/for/82-changes-and-fixes-to-files-view (branch 82-changes-and-fixes-to-files-view not found)

Branch not found? Hm... Something came to my mind, that docs said something about manually creating a branch, via Gerrit UI, before pushing changes. Am I right? Anyway, I'm doing so. I'm creating a branch, through UI, giving it above name (82-changes-and-fixes-to-files-view) and corresponding revision, taken from git status (2b25fe7612f1563a78c9dc2d1574ae3dcfe9d5a1). And, again...

git push origin HEAD:refs/for/82-changes-and-fixes-to-files-view

(crunch, cruch)

! [remote rejected] HEAD -> refs/for/82-changes-and-fixes-to-files-view (no new changes) 

Eee... What am I missing? How can Gerrit claim, that there are no changes, if I actually haven't pushed any code to it yet (there is no such change, of course, of above name, recorded in neither open nor merged changes in Gerrit UI)?


回答1:


The solution to this problem is to always use current HEAD's last commit ID, not the one from commit made to your branch. Using branch's last commit ID is wrong. Why -- this is beyond my imagination.

So, correct path is:

  1. Create branch using UI and giving HEAD's revision.
  2. Push changes (that branch) to Gerrit, don't forget about correct refs.
  3. Visit page, which URL Gerrit gave you as a result of your push and review your change or wait for someone else to review it.

As alternative, you can simply click Create Branch with Initial Revision field empty, so Gerrit will auto-fill it. Then push Create Branch button again.

EDIT: This answer only explains, what to do, to get change accepted by Gerrit. It doesn't explains, why in previous approach (explained in question), Gerrit is claiming, that there are no changes and does not accept the code, while it actually have not code at all (for that particular branch). For me, this is a huge bug, that leads to a code losses. (incorrect as per comment below)



来源:https://stackoverflow.com/questions/20583800/gerrit-doesnt-accept-newly-created-change-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!