Okay, now we know that there is no need to panic if you made a mistake while naming your git branch. You need to run the below command to delete the remote branch with the old name. Pushing the branch to remote with the new name will now delete the old branch on the remote.Once the branch is renamed on local, run the below command to push the renamed branch to remote $ git push origin -u.In the previous stage, we rename the git branch on local and now we will follow these steps to update the branch name on remote as well. If your old git branch was only on your local and not pushed to remote then you can stop here.īut if you have the wrong branch name on remote as well then continue reading. To check if the branch is renamed correctly you can run the "git branch" or "git status" command to check your current branch $ git branch $ git status.Now you can run the "git branch" command with -m and the new branch name.The first step to rename a branch is to checkout the branch you might want to rename.Now let's see how to rename a git branch on local with these steps: Sometimes you might make a typo mistake while naming your branch and want to make it perfect by renaming it.You might have the wrong branch name or a wrong ticket number in your branch name.You might want to rename your git branch if the branch name does not match your project branch naming standards.Why you might want to rename the git branch name?īefore going into details of how to rename local and remote git branches, let's see the reason why you might want to do it: Now let's go through some detail on why and how to rename a git branch on local and remote. Once the branch is renamed on local you can push the new branch to remote and delete the old git branch on the remote. Git branch can be renamed with a simple command "git branch -m ", this will rename your current git branch name. Made a small mistake while naming your git branch, don't panic this blog post will go through all the possibilities for renaming the git branch on local and remote.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |