Go straight to the point. In the previous article, there are two solutions mentioned in the error report when creating a branch . This article will talk about the second one. If the branch is not deleted, how to modify the branch name?
For example, the name of the new branch is newBranch, and the name of the branch to be modified is oldBranch. This name is more grounded.
The specific operation steps are as follows:
1. Rename the branch
git branch -m oldBranch newBranch
Note that if the modified branch is only local and has not been pushed to the remote, you only need to perform this operation. The following steps are for branches that have been pushed to the remote.
2. Delete the remote branch
git push --delete origin oldBranch
3. Upload the newly named local branch
git push origin newBranch
4. The local branch is associated with the remote branch
git branch --set-upstream-to origin/newBranch
Among them, the commands in steps 3 and 4 can also be directly replaced by the following commands.
git push -u origin newBranch