Skip to content

Instantly share code, notes, and snippets.

@stuartsoft
Last active June 27, 2020 03:04
Show Gist options
  • Save stuartsoft/9e2b5bd87e495447d7f47777d87d3d61 to your computer and use it in GitHub Desktop.
Save stuartsoft/9e2b5bd87e495447d7f47777d87d3d61 to your computer and use it in GitHub Desktop.
Replaces 'master' branch with 'main' branch for all projects in a desired directory
#!/bin/bash
#usage: $ ./rename-branch.sh ~/yourProjectsDirectory
cd $1
folders=$(ls)
for f in $folders; do
cd $f
echo $f
git checkout -b main
git push --set-upstream origin main
git branch -d master
cd $1
done
#This script uses the MIT License
#Copyright (c) 2020 Stuart Bowman
#https://choosealicense.com/licenses/mit/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment