![]() ![]() Leave a comment if you need to know more about renaming your git branch and do check out our blog post on basic git commands you should know. We have seen why might need to rename your git branch, how to rename a branch on local, and then how to push it to the remote repository if required.Īnd always remember to remove the old git branch from the remote to make sure no one uses it. 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. > git status On branch master Changes to be committed: (use 'git reset HEAD .' to unstage) modified: index.However, doing just this tonight I ended up reverting to git mv. But now this change is only in your local git folder, what you need to do. Now you can rename the local branch with the following command: git branch -m main. Now you can run the "git branch" command with -m and the new branch name Git will recognise the file from the contents, rather than seeing it as a new untracked file, and keep the change history. First thing to do is to checkout the master branch if you didnât already: git checkout master Also be sure you have the latest changes git pull origin master. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |