Skip to content

Instantly share code, notes, and snippets.

@abits
Created May 8, 2017 19:26
Show Gist options
  • Save abits/e97a6f5f0b3461c5e9d6048c3c2ce96f to your computer and use it in GitHub Desktop.
Save abits/e97a6f5f0b3461c5e9d6048c3c2ce96f to your computer and use it in GitHub Desktop.
Copy existing git repos to gitlab
#!/bin/bash
# Copy existing origin to gitlab
GITLABBASE="https://gitlab.com/api/v3/projects"
GITLABTOKEN="secretTokenReplaceMe"
CWD=`pwd`
REPOBASE="git@example.com"
NEWREPOBASE="git@gitlab.com: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