Last active
March 21, 2016 15:58
-
-
Save sshaw/ad568848621a845b6697 to your computer and use it in GitHub Desktop.
Batch update the GitHub user or organization in all repository remotes under the given directory.
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
# Batch update the GitHub user or organization in all repo remotes under the given directory. | |
# Does not work with JRuby. | |
# | |
# usage: usage: gh_update_remotes_owner dir oldorg neworg | |
gh_update_remotes_owner() | |
{ | |
if [ $# -lt 3 ]; then | |
echo "usage: gh_update_remotes_owner dir oldorg neworg" >&2 | |
return 1 | |
fi | |
root=$1 | |
oldorg=$2 | |
neworg=$3 | |
# Does not work with JRuby, even with $_.sub | |
find "$root" -type f -wholename '*/.git/config' -exec ruby -i -pe"sub %r|(github.com):$oldorg/|, '\1:$neworg/'" {} + | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment