Rename a branch locally and remotely in Git

git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
Script to rename a branch locally and remotely in Git.

#Git #Bash #Branch #cesarnog

2 Responses

Thanks for your snippet
@Henry You are welcomed Henry

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.