Last active
January 14, 2020 15:05
-
-
Save TheToddLuci0/57e732f289c3802fd33f07dee52d68cc to your computer and use it in GitHub Desktop.
Automatically sync multiple git remotes.
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
#!/usr/bin/env bash | |
# Simple bash script to sync an arbitrary number of git remotes. | |
# Should be fairly platform independant. (Confirmed to work with git bash on windows, | |
# and AWS CodeCommit remotes.) | |
# | |
# Written by @TheToddLuci0 | |
remotes=($(git remote -v | awk '{print $1}' | uniq )) | |
# Uncomment to force a awitch to master (This might cause merge conflicts) | |
#git checkout master | |
# Pull in all remotes | |
for remote in "${remotes[@]}" | |
do | |
git pull $remote master | |
done | |
# Push them all | |
for remote in "${remotes[@]}" | |
do | |
git push $remote | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment