Disable LFS tracking for internal Git remote

This commit is contained in:
li-shihao-code
2026-06-05 14:07:20 +08:00
parent f0c7196d49
commit 9ade43cf8f
3 changed files with 15 additions and 35 deletions
+8 -6
View File
@@ -8,7 +8,7 @@
# Notes:
# - If origin already exists, -r/--remote can be omitted.
# - If the working tree has changes, provide -m/--message to commit them.
# - Git LFS must be available on both local machine and remote hosting service.
# - This repository currently does not require Git LFS on the remote.
set -euo pipefail
@@ -91,12 +91,14 @@ command -v git >/dev/null 2>&1 || die "git is not installed."
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || die "Not inside a Git repository."
cd "$REPO_ROOT"
if ! git lfs version >/dev/null 2>&1; then
die "Git LFS is not installed. Install git-lfs before pushing this workspace."
LFS_COUNT="0"
if git lfs version >/dev/null 2>&1; then
git lfs install --local >/dev/null
LFS_COUNT="$(git lfs ls-files | wc -l | tr -d ' ')"
else
warn "Git LFS is not installed. This is acceptable only when no LFS files are tracked."
fi
git lfs install --local >/dev/null
if [[ -z "$BRANCH" ]]; then
BRANCH="$(git branch --show-current)"
fi
@@ -149,7 +151,7 @@ else
log "Working tree is clean."
fi
log "LFS files tracked: $(git lfs ls-files | wc -l | tr -d ' ')"
log "LFS files tracked: $LFS_COUNT"
log "Pushing branch '$BRANCH' to '$REMOTE_NAME'."
git push -u "$REMOTE_NAME" "$BRANCH"