Skip to main content

git/README.md

1# git
3These scripts are all shortcuts for using [Git], mostly designed to let me do my common Git tasks with as little typing as possible.
5[Git]: https://git-scm.com/
7## The individual scripts
9<!-- [[[cog
11# This adds the root of the repo to the PATH, which has cog_helpers.py
12from os.path import abspath, dirname
13import sys
15sys.path.append(abspath(dirname(dirname("."))))
17import cog_helpers
19folder_name = "git"
21scripts = [
22 {
23 "variants": ["bad", "good"],
24 "description": """
25 alias for <a href="https://git-scm.com/docs/git-bisect"><code>git bisect bad / good</code></a>
26 """
27 },
28 {
29 "name": "cleanup_branches",
30 "description": """
31 clean up any local branches which have been merged into the primary branch (<code>main</code>, <code>master</code>, etc.)
32 """
33 },
34 {
35 "usage": "gb [name]",
36 "description": """
37 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout -b [name]</code></a>, which creates a new branch
38 """
39 },
40 {
41 "usage": "gc [name]",
42 "description": """
43 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout</code></a>, which switches to the given branch
44 """
45 },
46 {
47 "usage": "gcb",
48 "description": """
49 <strong>g</strong>et the name of the <strong>c</strong>urrent <strong>b</strong>ranch
50 """
51 },
52 {
53 "usage": "gf",
54 "description": """
55 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git fetch origin --prune</code></a>, which gets updated information about all the branches on the remote server
56 """
57 },
58 {
59 "usage": "gitstats",
60 "description": """
61 print a brief line count summary of my local Git changes (any staged and uncommitted changes)
62 <p>
63 <pre><code>$ gitstats
64 +++ 0 additions
65 --- 57 deletions</code></pre>
66 </p>
67 """
68 },
69 {
70 "usage": "gm",
71 "description": """
72 switch to the primary branch (usually <code>main</code>, hence <code>gm</code>) and pull any changes from the remote server
73 """
74 },
75 {
76 "usage": "gp",
77 "description": """
78 <strong>p</strong>ull any changes on the current branch from the remote server
79 """
80 },
81 {
82 "usage": "gpr",
83 "description": """
84 open a GitHub <strong>p</strong>ull <strong>r</strong>equest for the current branch
85 """
86 },
87 {
88 "usage": "groot",
89 "description": """
90 alias for <code>git rev-parse --show-toplevel</code>, which prints the root of the current repository
91 """
92 },
93 {
94 "usage": "gub",
95 "description": """
96 open the current Git repo in my web browser (assuming it's a GitHub repo)
97 """
98 },
99 {
100 "usage": "gup",
101 "description": """
102 open the current Git repo in <a href="https://gitup.co/">GitUp</a>, my GUI Git client of choice
103 """
104 },
107cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
109]]]-->
110<dl>
111 <dt>
112 <a href="https://github.com/alexwlchan/scripts/blob/main/git/bad">
113 <code>bad</code>
114 </a>
116 <a href="https://github.com/alexwlchan/scripts/blob/main/git/good">
117 <code>good</code>
118 </a>
119 </dt>
120 <dd>
121 alias for <a href="https://git-scm.com/docs/git-bisect"><code>git bisect bad / good</code></a>
122 </dd>
124 <dt>
125 <a href="https://github.com/alexwlchan/scripts/blob/main/git/cleanup_branches">
126 <code>cleanup_branches</code>
127 </a>
128 </dt>
129 <dd>
130 clean up any local branches which have been merged into the primary branch (<code>main</code>, <code>master</code>, etc.)
131 </dd>
133 <dt>
134 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gb">
135 <code>gb [name]</code>
136 </a>
137 </dt>
138 <dd>
139 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout -b [name]</code></a>, which creates a new branch
140 </dd>
142 <dt>
143 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gc">
144 <code>gc [name]</code>
145 </a>
146 </dt>
147 <dd>
148 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout</code></a>, which switches to the given branch
149 </dd>
151 <dt>
152 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gcb">
153 <code>gcb</code>
154 </a>
155 </dt>
156 <dd>
157 <strong>g</strong>et the name of the <strong>c</strong>urrent <strong>b</strong>ranch
158 </dd>
160 <dt>
161 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gf">
162 <code>gf</code>
163 </a>
164 </dt>
165 <dd>
166 alias for <a href="https://git-scm.com/docs/git-checkout"><code>git fetch origin --prune</code></a>, which gets updated information about all the branches on the remote server
167 </dd>
169 <dt>
170 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gitstats">
171 <code>gitstats</code>
172 </a>
173 </dt>
174 <dd>
175 print a brief line count summary of my local Git changes (any staged and uncommitted changes)
176 <p>
177 <pre><code>$ gitstats
178 +++ 0 additions
179 --- 57 deletions</code></pre>
180 </p>
181 </dd>
183 <dt>
184 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gm">
185 <code>gm</code>
186 </a>
187 </dt>
188 <dd>
189 switch to the primary branch (usually <code>main</code>, hence <code>gm</code>) and pull any changes from the remote server
190 </dd>
192 <dt>
193 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gp">
194 <code>gp</code>
195 </a>
196 </dt>
197 <dd>
198 <strong>p</strong>ull any changes on the current branch from the remote server
199 </dd>
201 <dt>
202 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gpr">
203 <code>gpr</code>
204 </a>
205 </dt>
206 <dd>
207 open a GitHub <strong>p</strong>ull <strong>r</strong>equest for the current branch
208 </dd>
210 <dt>
211 <a href="https://github.com/alexwlchan/scripts/blob/main/git/groot">
212 <code>groot</code>
213 </a>
214 </dt>
215 <dd>
216 alias for <code>git rev-parse --show-toplevel</code>, which prints the root of the current repository
217 </dd>
219 <dt>
220 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gub">
221 <code>gub</code>
222 </a>
223 </dt>
224 <dd>
225 open the current Git repo in my web browser (assuming it's a GitHub repo)
226 </dd>
228 <dt>
229 <a href="https://github.com/alexwlchan/scripts/blob/main/git/gup">
230 <code>gup</code>
231 </a>
232 </dt>
233 <dd>
234 open the current Git repo in <a href="https://gitup.co/">GitUp</a>, my GUI Git client of choice
235 </dd>
236</dl>
237<!-- [[[end]]] (sum: vSOg0LYPZG) -->