@echo off setlocal ENABLEDELAYEDEXPANSION :: Ensure we're inside a Git repository git rev-parse --git-dir > NUL 2>&1 if ERRORLEVEL 1 ( echo Error: This directory is not a Git repository. exit /b 1 ) :: Get the current branch name FOR /F "delims=" %%i IN ('git symbolic-ref --short HEAD') DO SET CURRENT_BRANCH=%%i :: Check if the current branch is 'development' if NOT "!CURRENT_BRANCH!"=="development" ( echo Error: You are not on the 'development' branch. echo Please switch to the 'development' branch and run this script again. exit /b 1 ) :: Prompt for a commit message set /p COMMIT_MESSAGE=Enter your commit message: if "%COMMIT_MESSAGE%"=="" ( echo Error: Commit message cannot be empty. exit /b 1 ) :: Add all changes git add --all :: Show the changes to be committed echo The following changes will be committed: git status --short :: Prompt for confirmation to commit set /p CONFIRMATION=Do you want to proceed with the commit and push to 'development' branch? (yes/no): if /I NOT "%CONFIRMATION%"=="yes" ( echo Aborting commit and push to 'development' branch. exit /b 0 ) :: Commit the changes with the provided message git commit -m "%COMMIT_MESSAGE%" :: Show the last commit echo Last commit on 'development' branch: git --no-pager log -1 --pretty=format:"%%h - %%s (%%an, %%ar)" echo. :: Pull the latest changes from the remote 'development' branch git pull origin development --rebase :: Push the 'development' branch to the remote repository git push origin development echo Successfully pushed changes to 'development' branch.