@echo off chcp 65001 >nul echo ======================================== echo Git 代码提交脚本 echo ======================================== echo. REM 检查是否已经初始化Git仓库 if not exist ".git" ( echo [步骤1] 初始化Git仓库... git init echo. ) else ( echo [步骤1] Git仓库已存在,跳过初始化 echo. ) REM 检查是否已经添加远程仓库 git remote -v | findstr "origin" >nul 2>&1 if %errorlevel% neq 0 ( echo [步骤2] 添加远程仓库... git remote add origin http://115.190.64.57:8000/xiaoxue/peixu.git echo. ) else ( echo [步骤2] 远程仓库已存在 echo 当前远程仓库: git remote -v echo. echo 是否需要更新远程仓库地址?(Y/N) set /p update_remote= if /i "%update_remote%"=="Y" ( git remote set-url origin http://115.190.64.57:8000/xiaoxue/peixu.git echo 远程仓库地址已更新 echo. ) ) echo [步骤3] 查看当前状态... git status echo. echo [步骤4] 添加所有修改的文件... git add . echo. echo [步骤5] 输入提交信息 echo 请输入本次提交的描述(例如:修复快速派单功能、优化考核功能等): set /p commit_message= if "%commit_message%"=="" ( set commit_message=代码更新 - %date% %time% echo 使用默认提交信息:%commit_message% ) echo. echo [步骤6] 提交到本地仓库... git commit -m "%commit_message%" echo. echo [步骤7] 推送到远程仓库... echo 正在推送到 http://115.190.64.57:8000/xiaoxue/peixu.git echo. REM 首次推送需要设置上游分支 git push -u origin master 2>nul if %errorlevel% neq 0 ( echo 尝试推送到 main 分支... git push -u origin main 2>nul if %errorlevel% neq 0 ( echo. echo ⚠️ 推送失败,可能的原因: echo 1. 需要输入用户名和密码 echo 2. 远程仓库不存在或无权限 echo 3. 网络连接问题 echo. echo 请手动执行以下命令: echo git push -u origin master echo 或 echo git push -u origin main echo. pause exit /b 1 ) ) echo. echo ======================================== echo ✅ 代码提交成功! echo ======================================== echo. echo 远程仓库地址:http://115.190.64.57:8000/xiaoxue/peixu.git echo 提交信息:%commit_message% echo. pause