Last active
May 20, 2016 08:52
-
-
Save khoatran/3da16902b428e390a76565fd3b8c474e to your computer and use it in GitHub Desktop.
Move a git repository to a new one - keep all history. manual.txt for the case you want to do manually. gitmove.sh is a Linux Bash that help you do faster
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 "Please enter the source repository you want to move" | |
read SOURCE_REPOS | |
echo "Please enter the target repsitory that you want to move the repos" | |
read TARGET_REPOS | |
git clone --bare $SOURCE_REPOS | |
SOURCE_GIT_META_DIR=$(basename $SOURCE_REPOS) | |
cd $SOURCE_GIT_META_DIR && git push --mirror $TARGET_REPOS && cd .. && rm -rf $SOURCE_GIT_META_DIR |
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
git clone --bare git@github.com:{USERNAME}/{REPOSITORY_NAME}.git | |
cd {REPOSITORY_NAME}.git | |
git push --mirror git@myhost.com:my-new-repo.git | |
cd .. | |
rm -rf {REPOSITORY_NAME}.git | |
Now you have to change remote URL | |
git remote set-url origin git@myhost.com:my-new-repo.git | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment