Amit Prakash
Amit Prakash

Reputation: 1221

gerrit/git setup messed up when network disconnected in the middle. How to abandon the partial commits?

I was pushing my changes from local git repo to Gerrit using "git push origin HEAD:refs/for/master" when my network disconnected.

Now when I try to rerun it, I get:

Counting objects: 40, done. Delta compression using up to 8 threads. Compressing objects: 100% (28/28), done. Writing objects: 100% (36/36), 2.23 MiB, done. Total 36 (delta 4), reused 5 (delta 0) remote: Resolving deltas: 100% (4/4) remote: Processing changes: refs: 1, done
To ssh://@:29418/scaligent.git ! [remote rejected] HEAD -> refs/for/master (change 57 closed) error: failed to push some refs to 'ssh://@:29418/scaligent.git'

How do I clean up the state?

Upvotes: 0

Views: 287

Answers (1)

Tim Green
Tim Green

Reputation: 3649

Error message said everything

[remote rejected] HEAD -> refs/for/master (change 57 closed)

It's not caused by git push. Normally you get this error in such a case:

  • Push local commit to server as change 57 patchset 1
  • Modify something & git commit -amend
  • Someone(include yourself) click submit or abandon button in gerrit (which will close change 57)
  • Run git push again

Gerrit found you try to add a new patchset to a closed change, so revert the push.

Now you can clean it up by following step:

  • (optional) git branch -b backup
  • git fetch origin
  • git reset origin/master
  • git commit -a
  • git push origin HEAD:refs/for/master

Upvotes: 1

Related Questions