If you mistakenly named a branch and pushed it to the remote repository, follow these steps to rename it.
- Renaming your local branch:
- If you are on the branch you want to rename:
bash
git branch -m new-name - If you are on a different branch:
bash
git branch -m old-name new-name
- If you are on the branch you want to rename:
- Delete the remote branch
old-nameand push the local branchnew-name:git push origin :old-name new-name - Reset the upstream branch for the newly named local branch:
- Switch to the branch, then:
git push origin -u new-name
- Switch to the branch, then:
2024年6月29日 12:07 回复