Skip to content

Instantly share code, notes, and snippets.

@youngchief-btw
Last active October 27, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youngchief-btw/f3e2dfa2d701a4555f6c5be383384f31 to your computer and use it in GitHub Desktop.
Save youngchief-btw/f3e2dfa2d701a4555f6c5be383384f31 to your computer and use it in GitHub Desktop.
Rename a Local and Remote Git Branch (ex. master --> main)
#!/bin/bash
OLD_NAME=master
NEW_NAME=main
git checkout $OLD_NAME;
git branch -m $NEW_NAME;
# If already on remote do the following:
git push origin -u $NEW_NAME;
git push origin --delete $OLD_NAME:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment