Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Move branches names on a local repo and push change to the remote. Defaults master -> main
#!/bin/bash
oldb="${1:-master}"
newb="${2:-main}"
git pull --all
git checkout $oldb
git branch -m $oldb $newb
git push -u origin $newb
read -p "from the GitHub repo settings change the default branch to $newb. Press any key when done" x
git push origin --delete $oldb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment