There are three options:
First - if you want to destroy every trace of the history of master
you can just set master
to dev
-- similar to the answers of @Krantisinh and @ashishmohite:
git branch -f master dev
If other people have build upon the old state of master
they are screwed. So talk to them before you do that.
Second - you want to keep the history of master but swap out the contents: Then you are doing a special merge like this:
git checkout master
# git merge -s theirs simulation
git merge -s ours dev
git branch temp_THEIRS
git reset --hard dev
git reset --soft temp_THEIRS
git commit --amend
git branch -D temp_THEIRS
This merges dev
into master
but takes all content from dev
-- no conflicts - no questions asked. This comes from https://stackoverflow.com/a/56368650/947357.
Third - (as per comment) if you want to throw away master
(as in "First") but also start master
without any history:
git checkout --orphan new-master
git commit -m "start from scratch again"
git branch --force -M new-master master
After that dev
and master
do not share any history.