Skip to content

Instantly share code, notes, and snippets.

@burmudar
Created March 17, 2022 16:41
Show Gist options
  • Save burmudar/fd458e2a5405c1c0b2840e70f067f7ea to your computer and use it in GitHub Desktop.
Save burmudar/fd458e2a5405c1c0b2840e70f067f7ea to your computer and use it in GitHub Desktop.
Update repo origin
#!/bin/bash
USERNAME="Burmudar"
NEW_USERNAME="burmudar"
SRC="~/development"
for dir in $(fdfind -H -t d -d 2 -p ".git" $SRC)
do
cd $dir
url=$(git remote get-url origin)
if [[ $url =~ "Burmudar" ]]; then
echo "--- $dir ---"
repo=$(echo $url | sed "s/$OLD_USERNAME/$NEW_USERNAME/g")
echo "updating repo: $repo"
git remote set-url origin $repo
echo $(git remote get-url origin)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment