You are working on a project and the team has defined a naming convention for git branches. You have created a branch and pushed all your changes then realized that your branch name has Uh o in it. You have to rename the branch. Git made it very easy for you to rename the branch using -m command. Follow these steps_
Checkout the branch.
git
checkout
Old_BranchName
Rename the local branch.
git
branch -m
New_BranchName
Push the new local branch and reset the upstream branch.
git
push origin -u
New_BranchName
Safely delete the old remote branch.
git
push origin --delete
Old_BranchName
Or
git
push origin
:Old_BranchName
That’s it, renaming is done for local and remote Git branch.
You can also rename the branch from another branch using these commands.
git
branch -m
Old_BranchName New_BranchName
git
push origin
:Old_BranchName
git
push origin -u
New_BranchName
Happy coding!
No comments:
Post a Comment