Remote branch renaming of Git

In general, there is no need to rename the remote branch, but recently in the project, I want to rename a development branch that is already a fait accompli to the corresponding dev branch, so there is such a need.

In fact, renaming is a lazy practice. It should have merged the branch to be renamed into the original dev branch, but after trying it, I found that there were too many conflicts, hundreds, so I was discouraged and simply renamed it. I also gave myself a warning this time. Functional branches should be merged into development as soon as possible. If you go too far, this is easy to happen. )

Renaming a remote branch is actually deleting the remote branch first, renaming the local branch and then pushing it up. The following operations are listed: (Suppose you are currently in a local branch? On the old, it should be renamed as new)

Look at git branch -avv again, and you will find that the upstream branch corresponding to the new branch is still origin/old, only with a gone logo, so we set the new branch as the upstream branch and push it at the same time.

Ok, now we have completed the renaming step. Our new branch now corresponds to origin/new, but the name has changed, and all submission history is still the same as the old one.