Skip to content

Instantly share code, notes, and snippets.

@ymek
Last active August 29, 2015 14:21
Show Gist options
  • Save ymek/a3f991b1ed46637fef03 to your computer and use it in GitHub Desktop.
Save ymek/a3f991b1ed46637fef03 to your computer and use it in GitHub Desktop.
Migrate Git Repo's Remote Origin And Set Tracking Branches
NEW_REMOTE="git@github.com:your/repo.git"
# Rename the old origin
# Add the new origin
# Push all local branches to new origin and set respective tracking branches
git remote rename origin old_origin
git remote add origin $NEW_REMOTE
git remote push --all -u origin
# NOTE: Could benefit from refactor to use a "git clone --mirror" flow
# which would push *all* branches on old_origin to the new origin,
# not just those locally checked-out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment