-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-commit-push.bat
More file actions
60 lines (51 loc) · 1.11 KB
/
Copy pathgit-commit-push.bat
File metadata and controls
60 lines (51 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@echo off
setlocal EnableExtensions
echo Current folder: %cd%
git rev-parse --is-inside-work-tree >nul 2>&1
if errorlevel 1 (
echo Error: current folder is not a Git repository.
pause
exit /b 20
)
git status --porcelain >nul 2>&1
if errorlevel 1 (
echo Error: failed to read Git status.
pause
exit /b 20
)
set "status="
for /f "delims=" %%i in ('git status --porcelain') do set "status=1"
if not defined status (
echo There are no changes to the repository.
pause
exit /b 10
)
set /p "commit_message=Enter the commit message: "
set "commit_message_check=%commit_message: =%"
if not defined commit_message_check (
echo Error: commit message cannot be empty.
pause
exit /b 30
)
git add --all
if errorlevel 1 (
echo Error: failed to stage files with git add --all.
pause
exit /b 40
)
git commit -m "%commit_message%"
if errorlevel 1 (
echo Error: failed to create commit.
pause
exit /b 50
)
git push
if errorlevel 1 (
echo Error: failed to push changes to remote.
pause
exit /b 60
)
echo Git operations completed successfully.
echo --------------------------------------
pause
exit /b 0