Skip to content

Instantly share code, notes, and snippets.

@jeremywadsack
Last active August 29, 2015 14:05
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 jeremywadsack/32480ed8693b369416b7 to your computer and use it in GitHub Desktop.
Save jeremywadsack/32480ed8693b369416b7 to your computer and use it in GitHub Desktop.
Change git remote after renaming origin organization at GitHub
# A one-line script to change the origin organization name.
#
# After renaming our organization at GitHub, I had 25 repos I needed to update locally.
# This script finds the current "origin", removes it and replaces it with a new one
# with the organization changed.
#
# Just change OLD_ORG and NEW_ORG below to the old and new organization names and run
# this in each repository.
f=`git remote -v | grep '^origin' | cut -c 8- | cut -d' ' -f 1 | uniq`; git remote remove origin; git remote add origin ${f/OLD_ORG/NEW_ORG}
# You should also, then update your remotes.
git remote update --prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment