Skip to content

Instantly share code, notes, and snippets.

@terabyte
Created March 25, 2022 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terabyte/78a57cb7f1aff3c0836553347abf6cc2 to your computer and use it in GitHub Desktop.
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.
#!/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