Skip to content

Commit 4c91e36

Browse files
committed
fix(deploy): prevent git fetch failure for checked-out branches
The worktree update path ran `git fetch origin "$BRANCH"` which, due to the bare repo's refspec (+refs/heads/*:refs/heads/*), tried to update the local branch ref. Git refuses this when the branch is checked out in a worktree, breaking main deployments on every push. Add --refmap="" to suppress the configured refspec so only FETCH_HEAD is updated. The subsequent `git reset --hard FETCH_HEAD` works as originally intended.
1 parent e9dd6b4 commit 4c91e36

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

infrastructure/nixos/modules/deploy.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ let
113113
echo "Updating worktree for $BRANCH..."
114114
cd "$BRANCH_DIR"
115115
# Fetch directly in the worktree — can't update the bare repo ref while
116-
# the branch is checked out, so use FETCH_HEAD + reset instead
117-
${pkgs.git}/bin/git fetch origin "$BRANCH"
116+
# the branch is checked out, so use FETCH_HEAD + reset instead.
117+
# --refmap="" suppresses the bare repo's configured refspec
118+
# (+refs/heads/*:refs/heads/*) which would try to update the local
119+
# branch ref and fail for checked-out branches.
120+
${pkgs.git}/bin/git fetch origin --refmap="" "refs/heads/$BRANCH"
118121
${pkgs.git}/bin/git reset --hard FETCH_HEAD
119122
fi
120123

0 commit comments

Comments
 (0)