What to do, when missed some key refs during push

2019-02-25 15:29发布

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!)

标签: git push gerrit
1条回答
Root(大扎)
2楼-- · 2019-02-25 15:43

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>.
查看更多
登录 后发表回答