Skip to content

Instantly share code, notes, and snippets.

@alecthegeek
Created July 29, 2020 06:05
Show Gist options
  • Save alecthegeek/639827ac6972152a42d98599dfb94fea to your computer and use it in GitHub Desktop.
Save alecthegeek/639827ac6972152a42d98599dfb94fea to your computer and use it in GitHub Desktop.
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