Git: Renaming a Branch

Git branches are an easy way to manage our code, and separate our copies of our code when we want to work on specific features. We can then merge our code back into our main branch, or even rebase it.

Sometimes, though we make a mistake in the naming…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Johnny Simpson

Git branches are an easy way to manage our code, and separate our copies of our code when we want to work on specific features. We can then merge our code back into our main branch, or even rebase it.

Sometimes, though we make a mistake in the naming of our branch. Maybe you wrote fea-ui-design instead of feat-ui-design, or maybe you just want to rename your branch completely. Fortunately, it's easy to rename a branch. First switch to the branch you want to rename using checkout:

git checkout my-branch

And then use the -m option on branch to rename it.

git branch -m new-branch

Now my-branch has been renamed to new-branch - it's as easy as that!


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Johnny Simpson


Print Share Comment Cite Upload Translate Updates
APA

Johnny Simpson | Sciencx (2022-10-25T19:49:47+00:00) Git: Renaming a Branch. Retrieved from https://www.scien.cx/2022/10/25/git-renaming-a-branch/

MLA
" » Git: Renaming a Branch." Johnny Simpson | Sciencx - Tuesday October 25, 2022, https://www.scien.cx/2022/10/25/git-renaming-a-branch/
HARVARD
Johnny Simpson | Sciencx Tuesday October 25, 2022 » Git: Renaming a Branch., viewed ,<https://www.scien.cx/2022/10/25/git-renaming-a-branch/>
VANCOUVER
Johnny Simpson | Sciencx - » Git: Renaming a Branch. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/25/git-renaming-a-branch/
CHICAGO
" » Git: Renaming a Branch." Johnny Simpson | Sciencx - Accessed . https://www.scien.cx/2022/10/25/git-renaming-a-branch/
IEEE
" » Git: Renaming a Branch." Johnny Simpson | Sciencx [Online]. Available: https://www.scien.cx/2022/10/25/git-renaming-a-branch/. [Accessed: ]
rf:citation
» Git: Renaming a Branch | Johnny Simpson | Sciencx | https://www.scien.cx/2022/10/25/git-renaming-a-branch/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.