#!/bin/sh # Rename 'master' branch in a git repository (and in its origin) to 'main'. # # Note: You may still need to update the default branch upstream. # # See also the "[init]" section in # https://svn.red-bean.com/repos/kfogel/trunk/.gitconfig (and then see # https://svn.red-bean.com/repos/kfogel/trunk/.config/git/template/HEAD). if [ ! -d .git ]; then # Yeah, I know, we might not be in the top-level. Patches welcome. echo "ERROR: Run this from within a git repository (a checkout)." >&2 exit 1 fi git branch -m master main git push -u origin main echo "" echo "Now go make sure the upstream default branch is set to 'main'" echo "in your upstream hosting site (most such sites won't let the" echo "next step work if 'master' is still the default branch). Once" echo "this is done, you can run 'git push --delete origin master'." echo ""