What to do, when missed some key refs during push to Gerrit

主宰稳场 提交于 2019-12-02 05:28:02

问题


I'm new to Git and even newer to Gerrit and got a little bit lost. My workflow was probably standard: create a new branch, do the magic, commit changes, push them to Gerrit's repo.

My newly pushed branch is visible in Gerrit's web UI, but change is not visible at all.

After reading this answer, Gerrit's docs and many more, I easily and quickly found, that I missed magical refs. Instead of git push origin HEAD:refs/for/{branch name} I did just git push origin.

Great! But, how to recover from this situation? Whenever I try to push again, this time with proper refs, I'm getting ! [remote rejected] (no new changes).

What does this mean and what can I do? Does it mean, that I can't fix this in any other way, than adding new changes, committing them and pushing again? (no, even pushing another commit didn't solve the problem, Gerrit merged new push into master, but completely dropped previous one; this is beyond my imagination, unfortunately!)


回答1:


You can:

  • delete the remote branch by git push origin :<branch>,
  • remove the commit from local branch git reset --soft HEAD^,
  • stash the modifications by git stash,
  • create the remote branch with you local branch by git push origin <branch>,
  • get back the uncommitted changes by git stash pop,
  • commit it, and push it to refs/for/<branch>.


来源:https://stackoverflow.com/questions/20542903/what-to-do-when-missed-some-key-refs-during-push-to-gerrit

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