Skip to content

Instantly share code, notes, and snippets.

@sshaw
Last active March 21, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshaw/ad568848621a845b6697 to your computer and use it in GitHub Desktop.
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.
# 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