-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitScript.bat
78 lines (62 loc) · 1.57 KB
/
GitScript.bat
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@echo off
setlocal enabledelayedexpansion
title Git Operation
set Op=%1
set Arg=%2
:: Up - git commit -a -m %Arg% & git push
:: Down - git pull & git checkout main
:: Log - git log --oneline
:: Cred - git config --global --unset credential.helper & git config --global credential.helper store
::echo Op: !Op!
::echo Arg: !Arg!
2>nul call :Option_!Op!
if errorlevel 1 call :Option_Default
exit /b
:Option_Up
if "!Arg!" == "" (
echo Usage: GitScript Up ^<Commit Messages^>
exit /b
)
echo Will execute: git commit -a -m !Arg!, git push
echo Press any key to continue, or press Ctrl-C to quit.
pause>nul
echo.
echo Commiting...
git add --all
git commit -a -m !Arg!
echo.
echo Pushing...
git push
goto End
:Option_Down
echo Will execute: git pull, git checkout main
echo Press any key to continue, or press Ctrl-C to quit.
pause>nul
echo.
echo Pulling...
git pull
echo.
echo Checking out...
git checkout main
goto End
:Option_Log
git log --oneline
exit /b
:Option_Cred
echo Will execute: git config --global --unset credential.helper, git --global config credential.helper store
echo Press any key to continue, or press Ctrl-C to quit.
pause>nul
git config --global --unset credential.helper
git config --global credential.helper store
goto End
:Option_Default
echo Usage: GitScript ^<Option^> [Optional Argument]
echo Available options:
echo Up Commit and push to remote, require optional argument: commit message
echo Down Pull and checkout main branch
echo Log Check git one-line log
echo Cred Remove and update credential in next operation
exit /b
:End
echo.
echo Command completed.