Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Giulia Chiola
Giulia Chiola

Posted on • Originally published atgiuliachiola.dev

How to rename a git branch

Rename local branch

To rename alocal branch in git

  • Move on the branch you want to rename
git checkout-b feature/wrong-name
Enter fullscreen modeExit fullscreen mode
  • Rename it locally
git branch-m feature/new-awesome-name
Enter fullscreen modeExit fullscreen mode

⚡️ Bonus tip

If you haveohmyzsh installed, you can use its shortcutgbm.

Rename remote branch

To rename aremote branch is quite longer:

  • Unset the upstream branch to unlink local and remote branch
git branch--unset-upstream
Enter fullscreen modeExit fullscreen mode

Note: if you followed the previous step, you don't have to delete local branch because you have already renamed it!

  • Update the upstream branch to the new one and push it
git push--set-upstream origin feature/new-awesome-name
Enter fullscreen modeExit fullscreen mode
  • Delete remote branch
git push origin--delete feature/wrong-name
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Front-end Developer. 👾Media engineer. ⚡Facing life one bug at a time. 🔥 Easily bribed with chocolate. 🍫 she/her.
  • Location
    Val di Susa, Italia
  • Education
    Media Engineer, Politecnico di Torino
  • Work
    Front-end web developer
  • Joined

More fromGiulia Chiola

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp