Created
March 25, 2022 03:41
-
-
Save terabyte/5ce40acf5d281a2550da941b8125d86e to your computer and use it in GitHub Desktop.
Script to fetch any updates and merge it into any currently unincorporated work, then push it.
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
#!/bin/bash | |
set -e | |
GIT_DIR=$HOME/projects/private_notes | |
# only do it if we have network | |
if ping -c1 -w5 -n 8.8.8.8 | grep -q '1 received'; then | |
# first fetch updates | |
git -C $GIT_DIR fetch -q origin > /dev/null | |
if [[ "x$(git -C $GIT_DIR status --porcelain)" == "x" ]]; then | |
git -C $GIT_DIR merge origin/master | |
fi | |
git -C $GIT_DIR fetch -q origin > /dev/null | |
git -C $GIT_DIR merge -q -m"Merging in update" origin/master > /dev/null | |
git -C $GIT_DIR push -q origin master > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment