Skip to content

Instantly share code, notes, and snippets.

@TheToddLuci0
Last active January 14, 2020 15:05
Show Gist options
  • Save TheToddLuci0/57e732f289c3802fd33f07dee52d68cc to your computer and use it in GitHub Desktop.
Save TheToddLuci0/57e732f289c3802fd33f07dee52d68cc to your computer and use it in GitHub Desktop.
Automatically sync multiple git remotes.
#!/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