Last active
December 13, 2022 16:18
-
-
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/
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
#!/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