Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

How can I rename a local Git branch?

How can I rename a local branch which has not yet been pushed to a remote repository?

Related:

Answer

Cancel
1
  • If the old_name branch is the default branch, you may get an error message like "The default branch of a project cannot be deleted". In that case, you need to git push the new_name branch creation first, change the default branch to it, and then git push the old_name branch removal. Oct 6, 2022 at 18:50