To rename a branch in Git we should use the git branch command followed by -m option.
git branch -m new-branch
git branch -m old-branch new-branch
git push origin --delete <old-branch>
git push origin -u <new_branch>
Or you can use an alternative way:
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
This article is contributed by Prakash. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.