Skip to content

Instantly share code, notes, and snippets.

@perifer
Created October 22, 2013 06:12
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 perifer/7095904 to your computer and use it in GitHub Desktop.
Save perifer/7095904 to your computer and use it in GitHub Desktop.
Change the origin remote url from github to bitbucket for all git repos inside the current folder and 3 levels down
# Change the origin remote url from github to bitbucket
# for all git repos inside the current folder and 3 levels down
CURRENT=`pwd`
for DIR in $(find . -name ".git" -type d -maxdepth 3)
do
cd "$DIR"
cd ..
OLDORIGIN=`git config --get remote.origin.url`
if [[ "$OLDORIGIN" == *github.com:goodold* ]]
then
echo "Changed origin URL for $DIR"
NEWNAME=`echo $OLDORIGIN | sed 's/github\.com/bitbucket\.org/'`
git remote set-url origin $NEWNAME
fi
cd "$CURRENT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment