Skip to content

Instantly share code, notes, and snippets.

@childnode
Last active June 24, 2016 10:05
Show Gist options
  • Save childnode/c03e32289a94fe4859f04b82fddf5d6d to your computer and use it in GitHub Desktop.
Save childnode/c03e32289a94fe4859f04b82fddf5d6d to your computer and use it in GitHub Desktop.
recursive `git update remote` #git #cmdline #script
## usage: `rgur origin currentRemote.example.com newRemote.example.com`
rgur ()
{
test -d .git && ( echo "found git repo in $i" && ( git remote set-url $1 $(git remote get-url $1 |sed -e 's/'$2'/'$3'/') );
echo "UPDATED $1 : $(git remote get-url $1)" ) || ( for i in *;
do
test -d "$i" && ( builtin cd "$i" && rgur $1 $2 $3);
done )
}
@childnode
Copy link
Author

see also rgfa.sh

@childnode
Copy link
Author

Eingereichter Verbesserungsvorschlag:
ersetze git remote get-url origin durch git config --get remote.origin.url da er ggf. sonst versucht das alte repo zu erreichen?!?! erschließt sich mir persönlich noch nicht, aber vielleicht kann mir das ja jemand erklären ;)

rgur ()
{
    test -d .git && ( echo "found git repo in $i" && ( git remote set-url $1 $(git config --get remote.origin.url |sed -e 's/'$2'/'$3'/') );
    echo "UPDATED $1 : $(git config --get remote.origin.url)" ) || ( for i in *;
    do
        test -d "$i" && ( builtin cd "$i" && rgur $1 $2 $3);
    done )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment