Created
June 4, 2018 01:53
-
-
Save subdavis/5ba04af688cc5716b92f6c409009082b to your computer and use it in GitHub Desktop.
Git Mirror to gitlab
This file contains hidden or 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
gmirror () { | |
mkdir -p ~/github.com/mirrors | |
[ -z $1 ] && echo "usage: gmirror new|update" && return; | |
case $1 in | |
new) | |
[ -z $2 ] && echo "usage: gmirror new username oldreponame newreponame" && return; | |
git clone --mirror [email protected]:$2/$3.git ~/github.com/mirrors/$4.git | |
pushd . | |
cd ~/github.com/mirrors/$4.git | |
git remote set-url --push origin [email protected]:$2/$4.git | |
popd | |
gmirror update | |
;; | |
update) | |
pushd . | |
cd ~/github.com/mirrors | |
for d in $(ls ~/github.com/mirrors) | |
do | |
echo "Updating $d" | |
cd $d | |
git fetch -p origin | |
git push --mirror | |
cd .. | |
done | |
popd | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment