git rename local branch code example
Example 1: git rename branch
git branch -m # Any Branch
git branch -m # Current Branch
# For windows if you get "Branch already exists" error
git branch -M
Example 2: git rename remote branch
# Rename the local branch to the new name
git branch -m
# Delete the old branch on remote - where is, for example, origin
git push --delete
# Or shorter way to delete remote branch [:]
git push :
# Push the new branch to remote
git push
# Reset the upstream branch for the new_name local branch
git push -u
Example 3: rename branch git
git branch -m
Example 4: git rename local branch
git branch -m
Example 5: edit branch name git
$ git checkout Branch-Name-You-Want-to-Change
$ git branch -m New-Branch-Name
Example 6: git rename branch
git branch –m old-name new-name
git push origin :old-name new-name
git push origin –u new-name