Skip to content

Instantly share code, notes, and snippets.

@akash02-das
Last active July 28, 2023 22:05
Show Gist options
  • Select an option

  • Save akash02-das/64aa840c4ed0c986183f7334988676af to your computer and use it in GitHub Desktop.

Select an option

Save akash02-das/64aa840c4ed0c986183f7334988676af to your computer and use it in GitHub Desktop.
Rename a Local and Remote Git Branch

Rename a Local and Remote Git Branch

Follow the steps below to rename a Local and Remote Git Branch:

  • Start by switching to the local branch which you want to rename:

    git checkout 
  • Rename the local branch by typing:

    git branch -m 

    At this point, you have renamed the local branch. 😊

    If you’ve already pushed the <old_name> branch to the remote repository , perform the next steps to rename the remote branch.

  • Push the <new_name> local branch and reset the upstream branch:

    git push origin -u 
  • Delete the <old_name> remote branch:

    git push origin --delete 

That’s it. You have successfully renamed the local and remote Git branch. 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment