@echo off chcp 65001 >nul title Git Push cd /d "%~dp0\.." REM ========== Configure main branch name here ========== REM Leave empty to auto-detect (priority: master > main > current branch) set CONFIG_BRANCH=master REM ====================================================== REM Detect main branch if "%CONFIG_BRANCH%"=="" ( REM Auto-detect main branch git show-ref --verify --quiet refs/heads/master if %errorlevel% == 0 ( set MAIN_BRANCH=master ) else ( git show-ref --verify --quiet refs/heads/main if %errorlevel% == 0 ( set MAIN_BRANCH=main ) else ( REM If none found, use current branch for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set MAIN_BRANCH=%%i ) ) ) else ( REM Use configured branch set MAIN_BRANCH=%CONFIG_BRANCH% ) REM Push to main branch git push origin %MAIN_BRANCH% if errorlevel 1 ( echo. echo [ERROR] Push failed echo. pause ) else ( echo. echo [OK] Push successful echo. pause )