Overwrite everything in master with another branch in git

后端 未结 4 1933
迷失自我
迷失自我 2021-01-11 10:20

I have a very out of date master branch in a git repository.

All of my work has been done in another branch.

What is the best way to merge the

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-11 10:52

    A complete overwrite isn't merging the other content, it's abandoning it.

    git checkout -B master anotherbranch
    

    This has the advantage over a delete-and-recreate of retaining your branch settings and reflogs.

    If there's some administrative requirement to retain worthless commits in your history, follow that with git merge -s ours master@{1}. I prefer this sequence because it generates an unusual merge message, which will alert scanning --oneline logs that the merge is unusual.

提交回复
热议问题