diff --git a/php-test/gitops-deploy.sh b/php-test/gitops-deploy.sh index 567f7e5..7603f48 100755 --- a/php-test/gitops-deploy.sh +++ b/php-test/gitops-deploy.sh @@ -26,7 +26,8 @@ echo "" # 步骤 2: 提交到 Git echo -e "${BLUE}📝 步骤 2/4: 提交代码到 Git...${NC}" -git add . +# 只添加 php-test 目录的文件 +git add php-test/ if git diff --staged --quiet; then echo -e "${YELLOW}⚠️ 没有需要提交的更改${NC}" else @@ -38,11 +39,13 @@ echo "" # 步骤 3: 推送到远程仓库 echo -e "${BLUE}📤 步骤 3/4: 推送到远程仓库...${NC}" -if git push; then +CURRENT_BRANCH=$(git branch --show-current) +if git push -u origin ${CURRENT_BRANCH}; then echo -e "${GREEN}✅ 代码已推送到远程仓库${NC}" else echo -e "${RED}❌ 推送失败,请检查远程仓库配置${NC}" echo -e "${YELLOW}提示: 使用 'git remote -v' 查看远程仓库配置${NC}" + echo -e "${YELLOW}可能需要在 Gitea 中先创建仓库: https://git.u9.net3w.com${NC}" exit 1 fi echo ""