Skip to content

Instantly share code, notes, and snippets.

@justanotherdot
Last active June 16, 2020 22:13
Show Gist options
  • Save justanotherdot/1cfc3a9327988ac1df049bb80a8222d7 to your computer and use it in GitHub Desktop.
Save justanotherdot/1cfc3a9327988ac1df049bb80a8222d7 to your computer and use it in GitHub Desktop.
Rename local and remote to
#!/bin/sh -eux
# usage:
# cd into where you keep your git repositories then run this script.
# if you want to only update a single repository, comment out the loop
# below and calling this script from within the project you want changed.
update() {
git stash
# If you use something like GitHub, you will also
# need to do some GUI poking on the repos settings.
# Also be sure to update relevant CI details.
echo " + updating remote"
git checkout master
git branch -m master main
git push -u origin main
echo " + updating local"
git fetch
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
}
for dir in */; do
project="$(dirname $dir | xargs basename)"
cd "$dir"
echo "+ $project"
update
cd - >/dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment