Created
March 25, 2022 03:36
-
-
Save terabyte/78a57cb7f1aff3c0836553347abf6cc2 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 | |
# 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 | |
exit 0 | |
fi | |
git -C $GIT_DIR add -A | |
git -C $GIT_DIR commit -q -am "update $(date)" > /dev/null || exit 0 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment