1

I am trying to hard reset the master branch, so it mirrors the current state of our ‘develop’ branch.

We do not care for any old commits on master and want to rewrite it’s history. I should note, that we are using a self-hosted Git server called ‘SCM-Manager’ (no GitHub or similar services). I do have ‘owner’ privileges on the repository.

I am using the following command to force push the Develop’s state to Master:

git push origin +develop:master --no-verify --force

But I keep getting this error message:

! [rejected]            develop -> master (non-fast-forward)
error: failed to push some refs to 'https://****.git'
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.

Any help is highly appreciated.

6
  • 1
    The master -> master in the error message means your Git attempted to set their master to the same commit hash that is stored in your master. But your git push origin +develop:master should have your Git using the hash stored in your develop. Something here does not add up, in other words. Commented May 13, 2019 at 9:55
  • @torek You are right, the error message I provided was generated with my head on master. I edited the question, but the problem remains. Commented May 13, 2019 at 10:03
  • Should I approach this differently, like deleting the master branch and then recreating it from develop? Commented May 13, 2019 at 10:08
  • Have you checked the receive.denyFastForwards git config variable in your server repo? This config variable could cause the server repo to reject. I don't think this is the case, though, because the error message is (at least for me) different when the push is rejected because of that config variable. Commented May 13, 2019 at 10:52
  • Just to be sure, this is not about the order of paramters? I.e. --force that has to be in front of [<repository> [<refspec>…​]], like in git push --no-verify --force origin +develop:master. Commented May 13, 2019 at 10:59

1 Answer 1

0

I solved the issue by removing the ‘master’ branch as the default branch in the SCM-Manager console.

enter image description here

This allowed me to delete and then recreate the branch as a copy of the 'develop' branch.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.