Created
May 8, 2017 19:26
-
-
Save abits/e97a6f5f0b3461c5e9d6048c3c2ce96f to your computer and use it in GitHub Desktop.
Copy existing git repos to gitlab
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 | |
# Copy existing origin to gitlab | |
GITLABBASE="https://gitlab.com/api/v3/projects" | |
GITLABTOKEN="secretTokenReplaceMe" | |
CWD=`pwd` | |
REPOBASE="[email protected]" | |
NEWREPOBASE="[email protected]:example" | |
REPOS=( "repo/example" ) | |
for REPO in "${REPOS[@]}" | |
do | |
NEWREPO=`echo "$REPO" | tr '/' '-'` | |
echo $NEWREPO | |
mkdir -p $REPO | |
git clone --mirror "$REPOBASE:$REPO.git" $REPO | |
cd $REPO | |
http --form --print=h POST $GITLABBASE private_token=$GITLABTOKEN name=$NEWREPO | |
git remote remove origin | |
git remote add origin $NEWREPOBASE/$NEWREPO.git | |
git push -u origin --all | |
git push -u origin --tags | |
cd $CWD | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment