Last active
October 21, 2020 11:21
-
-
Save crmitchelmore/72888315549fe33119a60e739e6ff5da to your computer and use it in GitHub Desktop.
To update your origins to https
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a personal access token from github and enable SSO for it. | |
# Change in to the directory containing your repos | |
# cd /path/to/your/repo/dir | |
# git clone https://gist.github.com/crmitchelmore/72888315549fe33119a60e739e6ff5da | |
# mv 72888315549fe33119a60e739e6ff5da/update-origins.sh . | |
# rm -rf 72888315549fe33119a60e739e6ff5da | |
# chmod +x update-origins.sh | |
# GH_PAT=PASTyourPAThere ./update-origins.sh | |
# Wait :) | |
OLD_REMOTE="[email protected]:DigitalInnovation" | |
NEW_REMOTE="https://[email protected]/DigitalInnovation" | |
find "${PWD}" -type d -name '.git' | while read dir; do | |
cd "${dir}/.." | |
pwd | |
current_remote_url=$(git remote get-url "origin") | |
if grep "${OLD_REMOTE}" <<< "${current_remote_url}"; then | |
new_remote_url=$(sed "s~${OLD_REMOTE}~${NEW_REMOTE}~" <<< "${current_remote_url}") | |
echo "Changing ${current_remote_url} to ${new_remote_url}" | |
git remote set-url "origin" "${new_remote_url}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment