0

I would like to solve a problem I am having and learn the correct way of doing things.

My situation

I pull code from a gitlab repository. I created a feature branch, and edited one source file and then committed it. Then I pushed it with git push origin FeatureBranch. As a result of this I got a merge request.

However I left it for a couple of days.

Turns out that other people have modified the code and merged it into the master branch so The source branch is 7 commits behind the target branch

So, I do this

git fetch origin master
git checkout master
git tag last_master2
git merge origin/master
git checkout FeatureBranch
git rebase master
git push origin FeatureBranch

and I got the error

To https:<gitlab repo>
 ! [rejected]        FeatureBranch -> FeatureBranch (non-fast-forward)
error: failed to push some refs to <gitlab repo>
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

So my questions are:

  • What did I do wrong?
  • How do I do this right?
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • In this particular case, since you have rebased successfully, you probably want the `git push --force-with-lease` option. – torek Mar 03 '22 at 00:03

0 Answers0