From 71b4d44d2052b2994e404f61bf7c5383b2c52d25 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 19 Mar 2021 08:31:55 +0000 Subject: [PATCH] Push if local and remote don't match --- bash/.bash_functions | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bash/.bash_functions b/bash/.bash_functions index 29610c0..0dc63cb 100644 --- a/bash/.bash_functions +++ b/bash/.bash_functions @@ -64,10 +64,14 @@ function commit-pkm() { cd ~/Documents/pkm if [[ `git status --porcelain` ]]; then echo "Changes detected, commiting..." - git add -A && git commit -a -m 'Manual savepoint' && git push origin + git add -A && git commit -a -m 'Manual savepoint' else echo "No changes detected" fi + git fetch + if [ $(git rev-parse main) != $(git rev-parse refs/remotes/origin/main) ]; then + git push origin + fi cd $PREVDIR fi }