0

I have a master (main) branch and a develop branch with another code.

We realized that all the code from the master is obsolete and should be entirely replaced by the the develop branch (clean develop, without any additional master files, any merge).

master should remain the main (production) branch

Automatic merge failed because of conflicts.

enter image description here

Edit: after Eric's sugestion I did the following

git checkout master
git reset --hard develop
git push --force

And obtained:

enter image description here

fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use

git push origin HEAD:<name-of-remote-branch>

and this

enter image description here

serge
  • 13,940
  • 35
  • 121
  • 205
  • 1
    Why did it fail? On which files? Have you tried fixing merge conflicts manually? That's going to happen sometimes. – underscore_d Jan 15 '21 at 12:11
  • I don't need to resolve any conflict, I just need to replace my master with the develop version. – serge Jan 15 '21 at 12:12

1 Answers1

1
  1. Checkout master (git checkout master)
  2. Reset to develop (git reset --hard develop)
  3. Force push (git push --force)

This tells git to make master point to the same commit as develop. You need to force-push, because you are changing the history of master. After the steps your master will be the same as develop.

Be careful though. I would record the current commit IDs of develop and master to be able to go back to the previous state, in case the result turns out not to be what you want.

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103