Skip to content

Instantly share code, notes, and snippets.

@elnygren
Created August 11, 2016 06:30
Show Gist options
  • Save elnygren/3497b46da519445fd53081f5695a29da to your computer and use it in GitHub Desktop.
Save elnygren/3497b46da519445fd53081f5695a29da to your computer and use it in GitHub Desktop.
Move git projects the hard way
from subprocess import call
OLD_URLS = [
'[email protected]:someone/some-project.git'
]
NEW_URLS = [
'[email protected]:someone/some-project.git'
]
for idx, old_url in enumerate(OLD_URLS):
new_url = NEW_URLS[idx]
slash_pos = old_url.index('/')
directory = old_url[slash_pos+1:-len('.git')]
call(
"""
git clone --mirror {0} && \
cd {1} && \
git remote add new-origin {2} && \
git push new-origin --mirror
""".format(old_url, directory, new_url),
shell=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment