gitPushRemote.bat 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. @echo off
  2. setlocal
  3. :: 假设你已经处于正确的Git仓库目录中
  4. :: 添加所有更改到暂存区
  5. git add .
  6. echo Execute command: git add
  7. :: 等待用户输入提交信息
  8. set /p COMMIT_MESSAGE="Please enter the submission update information(default commit :first commit if no input):"
  9. echo 用户输入的提交信息为: %COMMIT_MESSAGE%
  10. set commitValue="first commit"
  11. :: 如果变量为空,则设置默认值为“第一次提交”
  12. if defined COMMIT_MESSAGE (
  13. set commitValue=%COMMIT_MESSAGE%
  14. )
  15. echo 用户输入的提交信息为: %commitValue%
  16. :: 执行git commit命令,使用用户输入的提交信息
  17. git commit -m %commitValue%
  18. :: 检查上一个命令是否成功(即提交是否成功)
  19. if %errorlevel% neq 0 (
  20. echo Git commit failed!
  21. @REM exit /b %errorlevel%
  22. ) else (
  23. echo Git commit successful!
  24. )
  25. :: 执行git push命令(假设你已经在本地master分支上并且想要推送到origin的master分支)
  26. git push -u origin master
  27. :: 检查上一个命令是否成功(即推送是否成功)
  28. if %errorlevel% neq 0 (
  29. echo Git push failed!
  30. @REM exit /b %errorlevel%
  31. ) else (
  32. echo Git push successful!
  33. )
  34. endlocal
  35. pause