| How can you rename a Local or Remote Branch in Git?
Git is one of the famous version control system which is used by software developers to keep track changes in their application and collaborate with others. One of the main feature of Git is branches.
Here different people works on different branches before merging their changes with the original code.
And you can add new features or fix bugs on a different branch without affecting to the original code.
And there are certain situation when you need to change the name of local branch or the remote branch. Below are the steps to change the name of branches:-
(1)Rename a local git branch:-
(i)In first step to see branche run below command
git branch --list or git branch -a
(ii)Now in second step switch to branch you want to rename by below command
git checkout branch-name
or we can use below command to switch to branch
git switch branch-name
(iii)In last step we will run the command to rename the branch
git branch -m new-name
(2)Rename a Remote git branch:-Rename a Remote banch is not same as local branch.
(1)In first step delete the old name by running below command
git push origin --delete old-branch-name
(2)In second and last step reset the upstream branch to the name of your new local branch by running below command
git push origin -u new-branch-name
And to check this rename log into your client website and check the repo. | | |