Skip to content

Instantly share code, notes, and snippets.

@blimmer
Last active June 17, 2020 20:20
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 blimmer/a7bf33cad9262f01a37be3aba35d881b to your computer and use it in GitHub Desktop.
Save blimmer/a7bf33cad9262f01a37be3aba35d881b to your computer and use it in GitHub Desktop.
A helper tool to fix local clones after renaming "master" branches to "main"
#! /bin/bash
set -e
if ! git diff-index --quiet HEAD --; then
echo "ERROR: you have uncommited changes. Please stash or commit before running this script."
exit 1
fi
git fetch
git checkout main
git pull origin main
delete_branch=$(git branch -D master) || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment