Problems with git operation

I now have two branches, one main branch of master and one branch of v3.40. I want to clear all the code and files on master and then merge the code on v3.40 into master. How to do this? only delete code and files, not delete branches
originally intended to merge directly, but dare not do so. The code difference between the two branches is too big for fear of too many problems and not easy to change

.
Git
Jul.06,2021

Welcome to follow my Wechat official account: please adopt the front-end guide if the answer is appropriate

1. Delete local master branch

2. Change the local x branch name to master branch

3. Force the local master branch to be pushed to the remote

git push origin master --force

then delete the code of the master branch first and submit it once, and then after the completion of other branches of merge, push


1, checkout master branch to A folder
2, checkout v3.40 branch to B folder
3, copy the source code in B folder to A folder
4, commit&push


in A folder.
Delete all file submissions, and then copy them over to submit. I don't think it's too good log is gone.
@ Gu Yuemeng the method given is correct
specific commands can be found as follows:
-sharp mastermaster_bak
git checkout master 
git branch master_bak

git checkout v3.40
-sharp master
git branch -D master
-sharp v3.40  master
git brnach --move master

-sharp master,
git push -uf origin master
one of the side effects of this is that if multiple people cooperate, pull master will have conflicts. It is best for others to reclone
.
Menu