![]() ![]() We were able to demonstrate how to correct the How To Rename A Branch In Git bug by looking at a variety of examples taken from the real world. Git branch -m # Change Name For Current Branch # you should check by git command : $ git branch : to check new branch name git branch -m # Change Name For Any Branch go to your branch that you want to rename Git push -u // Make sure you are in the project folder # Otherwise, git will use the old upstream name instead of. # Prevent git from using the old name when pushing in the next step. Git branch -M # Rename the local branch to the new name If you are on Windows or another case-insensitive filesystem, and there are only capitalization changes in the name, you need to use -M, otherwise, git will throw branch already exists error: Git config -global alias.rename 'branch -m' ![]() If you want to push the local branch and reset the upstream branch:Īnd finally if you want to Delete the remote branch:Ī way to remember this is -m is for "move" (or mv), which is how you rename files. If you want to rename the current branch, you can do: $ git branch -m New-Branch-Name If you want to rename a branch while pointed to any branch, do: $ git checkout Branch-Name-You-Want-to-Change The following paragraphs will examine the various alternative approaches. There are a number of different approaches that can be taken to solve the same problem. # Reset the upstream branch for the new_name local branch # Or shorter way to delete remote branch # Delete the old branch on remote - where is, for example, origin # Rename the local branch to the new name ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |