Skip to content

Instantly share code, notes, and snippets.

@cavinsmith
Last active May 9, 2018 04:33
Show Gist options
  • Save cavinsmith/5b59129696bd6919b1e8f569034e16ec to your computer and use it in GitHub Desktop.
Save cavinsmith/5b59129696bd6919b1e8f569034e16ec to your computer and use it in GitHub Desktop.
Easiest way to update repo origin when renaming organisation on GitHub

Updating repo origin when renaming organisation (if you have no repos with organisation name inside repo name)

git remote set-url origin `git config --get remote.origin.url | sed -e 's/OLD_ORG_NAME/NEW_ORG_NAME/g'`

The example above will have unintended bahavior if repo have organisation name inside repo name

e.g. you organisation is called bullshit and repo is called bullshit-backend - example above will rename both organisation and repository.

If you want to keep repo name unchanged check next example:

git config --get remote.origin.url | sed -e 's/github.com\/OLD_ORG_NAME/github.com\/NEW_ORG_NAME/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment