fix: use git fetch <branch> + checkout -B FETCH_HEAD for reliable branch switching

This commit is contained in:
2026-07-08 19:37:07 +08:00
parent 1dce2bb99d
commit 5d08dffa39
+3 -3
View File
@@ -18,9 +18,9 @@ fi
DEPLOY_BRANCH="${DEPLOY_BRANCH:-main}"
echo ">>> 拉取最新代码(分支: $DEPLOY_BRANCH,强制覆盖本地修改)..."
git fetch origin
git checkout "$DEPLOY_BRANCH"
git reset --hard "origin/$DEPLOY_BRANCH"
git fetch origin "$DEPLOY_BRANCH"
git checkout -B "$DEPLOY_BRANCH" FETCH_HEAD
echo ">>> 当前 commit: $(git rev-parse --short HEAD) $(git log -1 --format=%s)"
echo ">>> 安装前端依赖并构建..."
cd frontend