Skip to content

Instantly share code, notes, and snippets.

@Xnuvers007
Last active February 16, 2026 16:50
Show Gist options
  • Select an option

  • Save Xnuvers007/dbb17083b8328c081db8048d7d01a6d2 to your computer and use it in GitHub Desktop.

Select an option

Save Xnuvers007/dbb17083b8328c081db8048d7d01a6d2 to your computer and use it in GitHub Desktop.
@echo off
title AUTO GIT PUSH SCRIPT
color 0A
echo ================================
echo AUTO GIT PUSH
echo ================================
echo.
if not exist ".git" goto notRepo
echo.
set /p commitMsg=Enter your messages commit:
if "%commitMsg%"=="" goto emptyCommit
echo.
echo Choice Branch:
echo 1. main
echo 2. master
echo 3. custom (masukkan nama branch sendiri)
set /p branchChoice=Enter choice (1/2/3):
if "%branchChoice%"=="1" set branchName=main
if "%branchChoice%"=="2" set branchName=master
if "%branchChoice%"=="3" (
set /p branchName=Enter branch name:
)
if not defined branchName goto invalidBranch
git remote get-url origin >nul 2>&1
if errorlevel 1 goto addRemote
goto afterRemote
:addRemote
echo.
set /p shortURL=Enter Repo (example: username/repo.git):
if "%shortURL%"=="" goto emptyURL
set fullURL=https://github.com/%shortURL%
echo Remote will set to: %fullURL%
git remote add origin %fullURL%
:afterRemote
echo.
set /p pullChoice=Do you wanna git pull first ? (y/n):
if /I "%pullChoice%"=="y" (
echo.
echo Lets git pull...
git pull origin %branchName%
)
echo.
echo Adding file...
git add .
echo Commit changes...
git commit -m "%commitMsg%"
echo settings branch...
git branch -M %branchName%
echo Push to repository...
git push --set-upstream origin %branchName%
echo.
echo ================================
echo DONE!
echo ================================
pause
exit /b
:notRepo
echo This folder is not repository git!
echo Run: git init first.
git init
pause
exit /b
:emptyCommit
echo Commit messages required to fil!
pause
exit /b
:invalidBranch
echo Invalid Choice!
pause
exit /b
:emptyURL
echo URL required to set !
pause
exit /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment