Created
August 11, 2016 06:30
-
-
Save elnygren/3497b46da519445fd53081f5695a29da to your computer and use it in GitHub Desktop.
Move git projects the hard way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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