Skip to content

Instantly share code, notes, and snippets.

@Drarok
Last active January 2, 2016 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drarok/8286352 to your computer and use it in GitHub Desktop.
Save Drarok/8286352 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Convert 'http://github.com/user/repo' remotes to 'git://github.coim/user/repo'.
for GIT_DIR in $(find . -type d -name '.git'); do
export GIT_DIR
CURRENT_URL=$(git config --get remote.origin.url);
NEW_URL=$(echo $CURRENT_URL | sed 's/^http:/git:/');
NEW_URL=$(echo $NEW_URL | sed 's/^https:/git:/');
if [ "$CURRENT_URL" != "$NEW_URL" ]; then
echo "${GIT_DIR}: Changing URL from ${CURRENT_URL} to ${NEW_URL}";
git config remote.origin.url "$NEW_URL";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment