Skip to content

Instantly share code, notes, and snippets.

@pollend
Last active December 6, 2020 18:50
Show Gist options
  • Save pollend/6680caffe1f9cf81203f537adadef8b3 to your computer and use it in GitHub Desktop.
Save pollend/6680caffe1f9cf81203f537adadef8b3 to your computer and use it in GitHub Desktop.
#!/bin/bash
org=""
tg=""
for i in */; do
tg="$(git -C "$(pwd)/$i" remote -v | grep origin | grep "(fetch)" | sed -s 's/origin//g' | sed -s 's/(fetch)//g')";
if [[ $tg == *"http"* ]]; then
org="$(echo ${tg} | sed -s 's/https:\/\/github.com\//git@github.com:/g')";
git -C "$(pwd)/$i" remote remove origin
git -C "$(pwd)/$i" remote add origin "${org}"
echo "${org}";
fi;
echo ${tg}
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment