Updated Push Batch script
This commit is contained in:
@@ -1,8 +1,91 @@
|
|||||||
@echo off
|
@echo off
|
||||||
@echo Updates hochladen
|
setlocal enabledelayedexpansion
|
||||||
set /p Update=Comment:
|
|
||||||
@pause
|
echo Checking git repository status...
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Check if we're in a git repository
|
||||||
|
git rev-parse --git-dir >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Error: Not a git repository or git is not installed.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Check for changes (staged, unstaged, and untracked files)
|
||||||
|
git diff --quiet --exit-code
|
||||||
|
set staged_changes=%errorlevel%
|
||||||
|
|
||||||
|
git diff --quiet --cached --exit-code
|
||||||
|
set unstaged_changes=%errorlevel%
|
||||||
|
|
||||||
|
REM Check for untracked files
|
||||||
|
for /f %%i in ('git ls-files --others --exclude-standard ^| find /c /v ""') do set untracked_count=%%i
|
||||||
|
|
||||||
|
REM If no changes detected
|
||||||
|
if %staged_changes%==0 if %unstaged_changes%==0 if %untracked_count%==0 (
|
||||||
|
echo No changes detected in the repository.
|
||||||
|
echo Repository is up to date.
|
||||||
|
pause
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Show current status
|
||||||
|
echo Changes detected:
|
||||||
|
git status --porcelain
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Add all changes (staged, unstaged, and untracked)
|
||||||
|
echo Adding all changes...
|
||||||
git add .
|
git add .
|
||||||
git commit -m "%Update%"
|
|
||||||
|
REM Verify there are changes to commit after adding
|
||||||
|
git diff --quiet --cached --exit-code
|
||||||
|
if %errorlevel%==0 (
|
||||||
|
echo No changes to commit after adding files.
|
||||||
|
pause
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Prompt for commit message
|
||||||
|
echo.
|
||||||
|
set /p commit_msg="Enter commit message: "
|
||||||
|
|
||||||
|
REM Check if commit message is empty
|
||||||
|
if "!commit_msg!"=="" (
|
||||||
|
echo Error: Commit message cannot be empty.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Commit changes
|
||||||
|
echo.
|
||||||
|
echo Committing changes...
|
||||||
|
git commit -m "!commit_msg!"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Error: Failed to commit changes.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Push to remote repository
|
||||||
|
echo.
|
||||||
|
echo Pushing to remote repository...
|
||||||
git push
|
git push
|
||||||
@pause
|
if errorlevel 1 (
|
||||||
|
echo Error: Failed to push changes to remote repository.
|
||||||
|
echo This might be due to:
|
||||||
|
echo - No remote repository configured
|
||||||
|
echo - Network connectivity issues
|
||||||
|
echo - Authentication problems
|
||||||
|
echo - Need to pull changes first
|
||||||
|
echo.
|
||||||
|
echo You can try running 'git push' manually to see the specific error.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Success! Changes have been committed and pushed.
|
||||||
|
echo Commit message: !commit_msg!
|
||||||
|
pause
|
||||||
Reference in New Issue
Block a user