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 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
git checkout my-branch
And then use the
-m option on
branch to rename it.
git branch -m new-branch
my-branch has been renamed to
new-branch - it’s as easy as that!
More Tips and Tricks for Git
- How to Auto Compress Your CSS and JS with Git Hooks
- A Step by Step Guide to Git Branches
- How to move your Githooks to your Repo
- How to make Git forget a tracked file now in .gitignore
- How to make Git ignore file permission (chmod) changes
- Git Merge: Merging Changes from other Branches
- The Complete Beginners Guide to Getting Started with Git
- Git Stash - Everything about stashing changes in git
- Using Git to see recent changes in specified a time period
- How to add a Blank Directory to your Git Repository