Bläddra i källkod

Fix dw update failing on divergent branches

Replace git pull with fetch + reset --hard to always match remote.
This handles force-pushed commits and divergent branches gracefully,
since the Pi should always track the remote branch exactly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tuanchris 4 månader sedan
förälder
incheckning
600ed760ef
1 ändrade filer med 5 tillägg och 2 borttagningar
  1. 5 2
      dw

+ 5 - 2
dw

@@ -107,7 +107,10 @@ cmd_update() {
     if [[ "$1" != "--continue" ]]; then
         echo "Pulling latest code..."
         git config --global --add safe.directory "$INSTALL_DIR" 2>/dev/null || true
-        git pull
+        local branch
+        branch=$(git rev-parse --abbrev-ref HEAD)
+        git fetch origin "$branch"
+        git reset --hard "origin/$branch"
 
         # Update dw CLI
         echo "Updating dw command..."
@@ -330,7 +333,7 @@ cmd_checkout() {
     # Checkout: create local tracking branch if it doesn't exist
     if git show-ref --verify --quiet "refs/heads/$branch"; then
         git checkout "$branch"
-        git pull
+        git reset --hard "origin/$branch"
     else
         git checkout -b "$branch" "origin/$branch"
     fi