I created a a new branch to one of my repos, then I did a couple of commits. At this moment I realized that the naming used for this new branch was wrong.
I was not sure how to do this from top of my head, and while quickly Googling, I realized as usual that there are apparently one millions way how people do their stuff.
Then I decided to ask ChatGPT (at least the one running in Bing) and gave the following steps:
- You can rename a Git branch with the following command:
git branch -m new-branch-name
- If you want to rename a local branch from inside another branch, use:
git branch -m old-name new-name
- If you want to rename a remote branch, delete it with:
git push origin --delete old-name
- Then push the renamed local branch with:
git push origin -u new-name
- You don’t have to remove the branch. You can simply rename it.
It did its job, I cannot complain, I know that I would have spent that way more time reading multiple possible answers from random blogs and/or Stackoverflow.