0

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?

4
  • 1
    You can rebase your branch onto the remote master Commented Apr 15, 2021 at 14:19
  • @MadPhysicist Thanks. Could you give some details or a link? Sounds like just what I need, but I can't see how to do it. Commented Apr 15, 2021 at 14:21
  • 1
    Search "git rebase tutorial". Command should be something like git checkout master; git rebase origin/master Commented Apr 15, 2021 at 14:33
  • 1
    @iBug Had trouble because I had to figure out how to unprotect the branch and then protect it again. (Does it seem like I am new at this?) But it worked out. Thanks! Commented Apr 15, 2021 at 14:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.