Skip to content

Commit 4c12eac

Browse files
authored
Add a Git cheat sheet (#2049)
Someone [on Mastodon](https://mastodon.online/@blami/115140353050908406) suggested it would be nice to have a cheat sheet on the Git website, so I thought I'd put together a prototype to see if it's of interest, perhaps for a future "Learn" section of the site. You can see it in action here: [Git cheat sheet](https://jvns.github.io/git-scm.com/cheat-sheet) There are definitely lots of Git cheat sheets out there already (for example [from github](https://training.github.com/downloads/github-git-cheat-sheet.pdf) and [from ndpsoftware](http://ndpsoftware.com/git-cheatsheet.html#loc=remote_repo;)), but it feels like it would be nice to have one that's lower tech and not GitHub branded. The content and styling both definitely need work -- right now it's basically an import of [this cheat sheet](https://wizardzines.com/git-cheat-sheet.pdf), which has some of my personal Git idiosyncracies in it (like insisting on using `HEAD^^^^^^` instead of `HEAD~5` 🙈). I got a bit carried away writing handwritten SVG Git graphs, and I'm not sure they'll display in all browsers as is. Here's what they're meant to look like. I think I'll figure out a better solution than the handwritten SVGs, maybe graphviz. <img width="300" alt="image" src="https://github.com/user-attachments/assets/d2f5175d-2a7f-4fbd-8ce1-8f300bf5d49f" />
2 parents 38f2060 + bef57b3 commit 4c12eac

File tree

5 files changed

+895
-0
lines changed

5 files changed

+895
-0
lines changed

assets/sass/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $baseurl: "{{ .Site.BaseURL }}{{ if (and (ne .Site.BaseURL "/") (ne .Site.BaseUR
2727
@import 'book2';
2828
@import 'lists';
2929
@import 'about';
30+
@import 'cheat-sheet';
3031
@import 'dark-mode';
3132
@import 'git-turns-20';
3233

assets/sass/cheat-sheet.scss

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
@import "variables";
2+
3+
.cheat-sheet {
4+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
5+
6+
.item {
7+
background: var(--bg-color);
8+
padding: 10px;
9+
border-radius: 10px;
10+
border: 1px solid var(--callout-color);
11+
display: flex;
12+
font-size: 1rem;
13+
flex-direction: column;
14+
gap: 5px;
15+
16+
p {
17+
font-size: 1rem;
18+
margin: 0 8px;
19+
}
20+
21+
h3 {
22+
color: var(--font-color);
23+
line-height: 1em;
24+
font-size: 1.1rem;
25+
margin-bottom: 8px;
26+
font-weight: 500;
27+
}
28+
29+
label {
30+
display: block;
31+
margin-top: 10px;
32+
}
33+
34+
code {
35+
background: var(--callout-color);
36+
color: var(--font-color);
37+
border-radius: 3px;
38+
padding: 4px 8px;
39+
font-family: Courier, monospace;
40+
margin-bottom: 0;
41+
}
42+
43+
h3 code {
44+
padding: 0;
45+
background: transparent;
46+
}
47+
48+
.or {
49+
font-weight: 700;
50+
font-size: 0.8em;
51+
display: block;
52+
margin-left: 30px;
53+
font-family: sans-serif;
54+
}
55+
}
56+
57+
section {
58+
margin-bottom: 20px;
59+
display: grid;
60+
gap: 10px;
61+
grid-template-columns: 1fr 1fr;
62+
63+
@media (max-width: $mobile-m) {
64+
& {
65+
display: flex;
66+
flex-direction: column;
67+
}
68+
}
69+
70+
h2 {
71+
grid-column: 1/3;
72+
73+
margin-top: 0;
74+
font-size: 1.2rem;
75+
font-weight: 700;
76+
line-height: 1.2;
77+
color: var(--orange);
78+
}
79+
}
80+
81+
.commit-reference {
82+
background: var(--callout-color);
83+
border-left: 4px solid var(--orange);
84+
display: block;
85+
padding: 10px;
86+
border-radius: 10px;
87+
88+
.intro {
89+
margin: 16px 0;
90+
}
91+
92+
dl {
93+
display: grid;
94+
grid-template-columns: auto 1fr;
95+
gap: 8px 16px;
96+
margin: 0;
97+
98+
dt {
99+
&::before {
100+
content: "";
101+
font-size: 18px;
102+
color: #666;
103+
}
104+
}
105+
106+
dd {
107+
font-family: monospace;
108+
padding: 4px 8px;
109+
}
110+
}
111+
}
112+
}

assets/sass/dark-mode.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
#l10n-versions-dropdown footer a {
153153
color: #6969dd;
154154
}
155+
156+
.cheat-sheet img {
157+
filter: invert(60%);
158+
}
155159
}
156160
}
157161

0 commit comments

Comments
 (0)