Skip to content

Instantly share code, notes, and snippets.

@blimmer
Last active June 17, 2020 20:20
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