Created
May 31, 2013 14:21
-
-
Save mohanarpit/5685300 to your computer and use it in GitHub Desktop.
This script migrates the local repository from an old remote origin to a new origin. Handy if you're migrating your repository from one service provider to another.
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
#!/bin/bash | |
echo "Input the path of the local repository: " | |
read localPath | |
echo "Input the URL of the new remote repo: " | |
read newRemote | |
cd $localPath | |
#Get the current remote repo | |
oldRemote=git remote -v | awk '{print $2}' | |
#Mirror the current repo in a local directory | |
git clone --mirror $oldRemote bare_repo/ | |
#Push the tree to the new repo | |
git push -f --all $newRemote | |
#Push the tags to the new repo | |
git push -f --tags $newRemote | |
#Update the remote origin in the local repo | |
git config remote.origin.url $newRemote | |
rm -rf bare_repo/ | |
cd - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks