In my local repo, I have series of commits, something like
A-B-C-D
At commit D
, I pushed to gitlab. No problem so far.
Then I needed to make an amend to D
. All I changed was the commit message. But now it was different, with a different ID. So I have
A-B-C-D*
I made a few more local commits
A-B-C-D*-E-F
And then I tried another git push
, and gitlab wouldn't take it:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '....'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
My first thought was to remove D from gitlab and then do the push again. (D, BTW, is still the HEAD as far as gitlab knows.) But I can't see how to do this. Is there a way? Failing that, is there some other way to correct the commit at gitlab and pick up where I left off?