This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.cmd
125 lines (115 loc) · 2.66 KB
/
git.cmd
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@ECHO OFF
:
: Interactive helper functions/aliases around git.
IF not "%1" == "" SHIFT & GOTO:%1
:::
: Outputs the current branch in the current directory.
: Arguments:
: None
: Outputs:
: Current local branch name of HEAD
: Returns:
: 1, if the underlying git command failed, 0 otherwise
:::
DOSKEY gitbr=git rev-parse --abbrev-ref HEAD
:::
: Pulls all branches and rebases the commits on the working changes.
: Arguments:
: None
: Outputs:
: Nothing
: Returns:
: 1, if the underlying git command failed, 0 otherwise
:::
DOSKEY gitpb=git pull --rebase
:::
: Attempts to pulls all branches and cancels the action on existing working changes.
: Arguments:
: None
: Outputs:
: Nothing
: Returns:
: 1, if the underlying git command failed (i.e. when working changes are available), 0 otherwise
:::
DOSKEY gitpf=git pull --ff-only
:::
: Pushes all branches to the remote.
: Arguments:
: None
: Outputs:
: Nothing
: Returns:
: 1, if the underlying git command failed, 0 otherwise
:::
DOSKEY gitpa=git push --all
:::
: Ammends the working changes into the last commit.
: Arguments:
: None
: Outputs:
: Nothing
: Returns:
: 1, if the underlying git command failed, 0 otherwise
:::
DOSKEY gita=git commit --amend --no-edit
GOTO:EOF
::: FUNCTIONS :::
:::
:
: Commits the current working changes using semantic commit messages.
: Arguments:
: %1 - Semantic scoped verb [ feat | fix | docs | style | refactor | test | chore ][!][@<scope>]?
: %* - Commit message
: Outputs:
: Verbose information or error
: Returns:
: 1, if the merge failed, 0 otherwise
:::
:gitco
SET "verb="
SET "scope="
FOR /F "tokens=1-2 delims=@" %%i IN ("%~1") DO (
SET "verb=%%~i"
SET "scope=%%~j"
)
IF NOT "%scope%" == "" (
IF NOT "%verb%" == "%scope%" (
SET "verb=%verb%(%scope%)"
)
)
SHIFT
git commit -m "%verb%: %*"
EXIT /B
:::
: Finds all commits of all branches with a given string in the description.
: Arguments:
: %1 - Fulltext search text for all commits
: Outputs:
: Verbose information about the result
: Returns:
: 1, if the query failed or nothing was found, 0 otherwise
:::
:gitfind
git log -G"%~1" -p --all
EXIT /B
:::
: Merges the current branch into the given branches.
: Repository must not have working changes active.
: Arguments:
: %* - Branchnames of the branches to merge into
: Outputs:
: Verbose information or error
: Returns:
: 1, if the merge failed, 0 otherwise
:::
:gitfuse
FOR /F "tokens=1 delims=*" %%i IN ('git rev-parse --abbrev-ref HEAD') DO @SET "current_branch=%%i"
FOR %%b in ("%*") DO (
IF not "%%b" == "%current_branch%" (
git checkout %%~b
git merge %current_branch%
)
)
git checkout %current_branch%
EXIT /B
:TODO: Add usage messages to functions.