Skip to content

Instantly share code, notes, and snippets.

@kraftwerk28
Created November 19, 2020 15:37
Show Gist options
  • Save kraftwerk28/004d3ff0853645c224f9641992ec5ad1 to your computer and use it in GitHub Desktop.
Save kraftwerk28/004d3ff0853645c224f9641992ec5ad1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
TOKEN="api-token"
master=${1:-"master"}
APIURL="https://api.github.com"
OWNER=$(git config --get user.name)
REPO=$(basename $(git rev-parse --show-toplevel))
git checkout -b master
git push origin master
curl -s -X PATCH "$APIURL/repos/$OWNER/$REPO" \
-d "{\"default_branch\":\"master\"}" \
-H "Authorization: token $TOKEN" > /dev/null
git push origin -d main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment