Skip to content

Instantly share code, notes, and snippets.

@alex-bellon
Created July 25, 2019 03:48
Show Gist options
  • Save alex-bellon/62279b5846a9afdd85ab125e51d9b1e1 to your computer and use it in GitHub Desktop.
Save alex-bellon/62279b5846a9afdd85ab125e51d9b1e1 to your computer and use it in GitHub Desktop.
Add a GitHub and GitLab repo as remote origins so that when you push, the changes are pushed to both repositiories. Useful for keeping a mirror of all your GitHub repos on GitLab. Does this for every directory in the present working directory.
for dir in */; do
repo=${dir%/*}
user="foo"
cd $dir
git remote remove origin
git remote add github git@github.com:$user/$repo.git
git remote add gitlab git@gitlab.com:$user/$repo.git
git remote add origin git@github.com:$user/$repo.git
git remote set-url --add --push origin git@github.com:$user/$repo.git
git remote set-url --add --push origin git@gitlab.com:$user/$repo.git
git pull origin master
git push --set-upstream origin master
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment