How do I rename the local Git branch? [duplicate]
Asked Answered
N

1

5

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

How can I rename a local branch which hasn't been pushed to a remote branch?

In case you need to rename remote branch as well: How do I rename both a Git local and remote branch name

Norsworthy answered 5/10, 2020 at 19:51 Comment(2)
You referenced the answer in both of your questions: git branch -m <old_name> <new_name>Glissade
Don't rename the branch, just create a new one at the same place. (If you then delete the original, I suppose you've accomplished a rename.)Lousy
B
14
git checkout <old_branch>

git branch -m <new_branch>

git push origin -u <new_branch>
Bowl answered 5/10, 2020 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.