From 5db0b3feff6888ecbd9f486312bd8ab6dedceb78 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Thu, 11 Apr 2024 23:08:55 +0100 Subject: [PATCH] Add guard for git-sync-all for non-main branch Only pull/push non-syncing repos (currently nixos and emacs) if on the "main" branch, echo warning message and skip otherwise. --- home/scripts/git-sync-all.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/home/scripts/git-sync-all.sh b/home/scripts/git-sync-all.sh index 6a6f1024..02457c5f 100755 --- a/home/scripts/git-sync-all.sh +++ b/home/scripts/git-sync-all.sh @@ -46,8 +46,12 @@ for i in "${!PULL_DIRS[@]}"; do fi ( cd "$DIRECTORY" || exit - git remote set-url origin "$URL" - git pull --ff-only - git push + if [ "$(git branch --show-current)" = "main" ]; then + git remote set-url origin "$URL" + git pull --ff-only + git push + else + echo "Not syncing repo $DIRECTORY on branch $(git branch --show-current)" + fi ) done