Search code examples
gitgit-pushscmmanager

Git force push failed


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.


Solution

  • 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.