Created
July 25, 2019 03:48
-
-
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.
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
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