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