Created
February 15, 2017 14:47
-
-
Save tarto-dev/51ea4e491faa409b0447678cb8136da2 to your computer and use it in GitHub Desktop.
This script allow you to easily migrate a repository from git server to another git server
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/sh | |
oldrepos="$2" | |
newrepos="$3" | |
reposname="$1" | |
clonefolder="/Applications/MAMP/htdocs/clonePldev/$reposname" | |
rootclonefolder="/Applications/MAMP/htdocs/clonePldev/" | |
R='\e[31m' | |
B='\e[36m' | |
N='\033[0m' | |
clear | |
printf "The command typed above will produce | |
${R}git clone --mirror ${B}$oldrepos${R} $clonefolder | |
cd ${B}$clonefolder${R} | |
git remote add ${B}$reposname $newrepos${R} | |
git push -f --tags ${B}$reposname${R} refs/heads/*:refs/heads/* | |
cd ${B}$rootclonefolder${R} | |
rm -rf ${B}$clonefolder${N} | |
" | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
git clone --mirror $oldrepos $clonefolder | |
cd $clonefolder | |
git remote add $reposname $newrepos | |
git push -f --tags $reposname refs/heads/*:refs/heads/* | |
cd $rootclonefolder | |
rm -rf $clonefolder | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment