Commit e5201646 authored by Hugo Buddelmeijer's avatar Hugo Buddelmeijer
Browse files

Add initial synchronize.sh

parent 5ed5832e
#!/usr/bin/env bash
# Echo commands and exit on first error
set -e
echo "Going to synchronize"
remotes=$(git remote)
echo "Synchronizing: ${remotes}" | tr '\n' ' '
echo
git checkout master
# Fetch changes from remotes.
for remote in $remotes; do
git fetch "${remote}"
theyahead=$(git rev-list --count "master..${remote}/master")
echo "Remote ${remote} is $theyahead ahead!"
if [ "${theyahead}" -gt 0 ]; then
git merge -m "Synchronize ${remote} into master" "${remote}/master"
fi
done
# Propagate changes to remotes.
for remote in $remotes; do
weahead=$(git rev-list --count "${remote}/master..master")
if [ "${weahead}" -gt 0 ]; then
echo "Propagating ${weahead} changes to ${remote}."
git push "${remote}" master
fi
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment