From cca64b873be0b68e909f5304fdfda07b1cb94411 Mon Sep 17 00:00:00 2001 From: z4yx Date: Fri, 22 May 2020 17:14:37 +0800 Subject: [PATCH] git remote set-head doesn't work with bare repo --- git.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git.sh b/git.sh index 7868367..9e404e9 100755 --- a/git.sh +++ b/git.sh @@ -14,7 +14,8 @@ function update_linux_git() { echo "==== SYNC $UPSTREAM START ====" git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p - git remote set-head origin --auto + head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}') + [[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD objs=$(find objects -type f | wc -l) [[ "$objs" -gt 8 ]] && git repack -a -b -d sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')