Skip to content

Instantly share code, notes, and snippets.

@daniel-vera-g
Last active April 7, 2021 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-vera-g/fcecac7103cae23ddfc80306d22fa7f0 to your computer and use it in GitHub Desktop.
Save daniel-vera-g/fcecac7103cae23ddfc80306d22fa7f0 to your computer and use it in GitHub Desktop.
Migrate multiple repositories from github to gitlab
#!/bin/bash
# To be used with: https://gist.github.com/daniel-vera-g/dc4df64ed1064406c8956f588c538d41
# Migrate multiple repositories from github to gitlab
# Name of repos to migrate
reposToMigrate=('')
# Name of gitlab domain
# If gitlab.com, adjust url below
domain=''
# User
user=''
for repo in "${reposToMigrate[@]}"; do
echo '--------------'
echo "Checking out: " $repo
echo '--------------'
# Clone from gitlab
git clone git@git.$domain.com:$user/$repo.git
cd $repo
echo '--------------'
echo "Create project on github"
echo "Uses github 'gh' cli tool"
echo '--------------'
# Optional --private and -t [team-name] flag(See gh --help)
gh repo create $repo -y
git remote add github git@github.com:$user/$repo
echo '--------------'
echo "Push all local branches and tags"
echo '--------------'
git push github --all
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment