-3

My master branch is very out to date. Like 100+ commits behind dev, is not longer needed anymore. If I merge with dev there are many conflicts I don't need to resolve. Plus, I have created a master-old branch just in case. How can I make dev as my master without having to resolve conflicts.

I tried:

  1. Destoy master an create it again from dev (not allowed by github)
  2. Rebase (It need to resolve conflicts)
  3. Flag --theirs (not sure how to use it)
Enzo
  • 4,111
  • 4
  • 21
  • 33
  • Delete master and rename dev? – Paolo May 24 '23 at 09:45
  • Just reset `master` on `dev`. It's probably the simplest way, and as a bonus the branch's reflog will be preserved (which is not the case if you delete/recreate the branch). – Romain Valeri May 24 '23 at 09:56
  • To clarify. @RomainValeri gave half of the answer, he pointed to this question as repeated: https://stackoverflow.com/questions/9210446/how-to-replace-local-branch-with-remote-branch-entirely-in-git. The problem of that answer is that does not explain how to `git push --force`. I found the other part of the solution here: https://superuser.com/questions/716818/how-to-overwrite-a-branch-in-git-with-master – Enzo May 24 '23 at 14:52

1 Answers1

-1

The easiest way:

git checkout master
git reset --hard dev
git push --force
Enzo
  • 4,111
  • 4
  • 21
  • 33