Skip to content

Instantly share code, notes, and snippets.

@Sekiphp
Last active December 13, 2022 16:18
Show Gist options
  • Save Sekiphp/cfaf2c2d96f0a2487fc8ed2d00782118 to your computer and use it in GitHub Desktop.
Save Sekiphp/cfaf2c2d96f0a2487fc8ed2d00782118 to your computer and use it in GitHub Desktop.
Mass change of git remotes for more repositories in same folder. Can be used for Magento 2 repositories located in app/code/Namespace/
#!/bin/bash
clear
prefix=""
ls -d */ | while read -r folder;
do
cd "$folder"
echo "Before:"
git remote -v
remote_reference=$(git remote get-url --push origin)
repository_name="${remote_reference##*/}"
git remote remove origin
git remote add origin "$prefix$repository_name"
git checkout master
git fetch
git branch --set-upstream-to=origin/master master
git pull
cd ..
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment