Error Handling
Error Handling
Detached HEAD
cd "$WORKSPACE_ROOT/$repo"
git checkout main 2>/dev/null || git checkout master
git pull --rebase origin main
Diverged History (force-pushed remote)
# Detect: behind > 0 AND ahead > 0
# DO NOT auto-resolve — ask user:
echo "$repo has diverged: $BEHIND behind, $AHEAD ahead"
echo "Options: merge, reset --hard origin/main, or skip"
Stash Pop Conflict
# Report to user, do NOT auto-resolve
echo "Stash pop conflict in $repo — manual resolution required"
git stash list
CRLF / Line Ending Issues
# Fix shell scripts to LF
git config core.autocrlf input
# Or per-file: dos2unix script.sh