![]() Step 2: Reset the upstream branch to the name of your new local branch by running git push origin -u new-branch-name. In the example I’ve been using, this would be git push origin -delete mistake-fixes Step 1: Delete the old name by running git push origin -delete old-branch-name To be precise, renaming a remote branch is not direct – you have to delete the old remote branch name and then push a new branch name to the repo.įollow the steps below to rename a remote git branch: Renaming a remote branch is not as straightforward as renaming a local branch. N.B.: Make sure you verify that the branch has been renamed by running git branch -a to see all branches. If you are on another branch, for example, main and you want to rename the branch from there, run git branch -m old-name new-name You can see that the branch has been renamed from mistake-fixes to bug-fixes Step 3: To rename the branch, run git branch -m new-name To switch to a branch, run git switch branch-name or git checkout branch-name. In this case, I’m going to switch to the mistake-fixes branch so I can rename it bug-fixes. Step 2: Switch to the branch you want to rename by running git checkout branch-name. Step 1: To see the branches you have, run git branch -list or git branch -a ![]() Sometimes, you might want to change the name of a branch because of typos or other errors, and that’s what I’m going to show you how to do in this guide. You can also add new features and fix bugs on a different branch without affecting the original code. Different people working on a software project can work in different branches before merging their changes with the original code. Git is a version control system that software developers use to keep track of changes in their applications and collaborate with others.
0 Comments
Leave a Reply. |