Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hugo Buddelmeijer
gitremotesync
Commits
e5201646
Commit
e5201646
authored
Jun 29, 2020
by
Hugo Buddelmeijer
Browse files
Add initial synchronize.sh
parent
5ed5832e
Changes
1
Hide whitespace changes
Inline
Side-by-side
synchronize.sh
0 → 100644
View file @
e5201646
#!/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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment