@echo off setlocal :: 假设你已经处于正确的Git仓库目录中 :: 添加所有更改到暂存区 git add . echo Execute command: git add :: 等待用户输入提交信息 set /p COMMIT_MESSAGE="Please enter the submission update information(default commit :first commit if no input):" echo 用户输入的提交信息为: %COMMIT_MESSAGE% set commitValue="first commit" :: 如果变量为空,则设置默认值为“第一次提交” if defined COMMIT_MESSAGE ( set commitValue=%COMMIT_MESSAGE% ) echo 用户输入的提交信息为: %commitValue% :: 执行git commit命令,使用用户输入的提交信息 git commit -m %commitValue% :: 检查上一个命令是否成功(即提交是否成功) if %errorlevel% neq 0 ( echo Git commit failed! @REM exit /b %errorlevel% ) else ( echo Git commit successful! ) :: 执行git push命令(假设你已经在本地master分支上并且想要推送到origin的master分支) git push -u origin master :: 检查上一个命令是否成功(即推送是否成功) if %errorlevel% neq 0 ( echo Git push failed! @REM exit /b %errorlevel% ) else ( echo Git push successful! ) endlocal pause