Solution:
Root Cause: Expired Cached Credentials or Missing Token LFS Scopes
Git LFS uses a separate HTTP client payload from core Git. While basic
git pull fetches lightweight commit metadata using cached SSH or HTTP credentials,
git lfs pull makes dedicated batch API calls (
POST /info/lfs/objects/batch). If your Git Credential Manager (GCM) holds a stale token, or if your Personal Access Token (PAT) lacks the explicit
read:packages or
write:packages (or repository access) permissions, the LFS API endpoint returns an
HTTP 401 or
HTTP 403 error.
# Diagnostic Verification:
Run the pull command with explicit Git LFS environment debugging enabled:
bash
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 GIT_CURL_VERBOSE=1 git lfs pull
Look for the raw batch API endpoint authorization headers in the output:
text
> POST /info/lfs/objects/batch HTTP/1.1
< HTTP/1.1 401 Unauthorized
LFS: [401] Credentials rejected or expired.
# Step-by-Step Fix:
1.
Purge Stale Credentials from System Vault:
On Windows (PowerShell): powershell
cmdkey /list | Select-String -Pattern "git"
cmdkey /delete:TargetName # Delete entries matching github.com or your host
On macOS: bash
security delete-internet-password -s github.com
2.
Re-authenticate via Git Credential Manager:
Ensure Git Credential Manager is set globally: bash
git config --global credential.helper manager
3.
Regenerate Personal Access Token (PAT) with Required Scopes:
If authenticating manually, generate a PAT with repo scope (for private repositories) or read:packages depending on hosting provider rules.Re-run git lfs pull and enter the newly generated token when prompted.# Prevention & Long-Term Monitoring:
Use short-lived OAuth tokens or official CLI helpers like gh auth login to keep credential stores automatically synchronized.