-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-guide.html
More file actions
1521 lines (1358 loc) · 66.5 KB
/
git-guide.html
File metadata and controls
1521 lines (1358 loc) · 66.5 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Git & GitHub: The Essential Field Guide for Developers</title>
<!-- Primary SEO -->
<meta name="description" content="A comprehensive Git and GitHub field guide covering cloning, branching, merging, pull requests, stash, revert, reset, and tags — with real-world examples and a quick-reference cheat sheet." />
<meta name="keywords" content="git tutorial, github guide, git commands, branching, merging, pull request, git stash, git revert, git reset, version control, beginner git" />
<meta name="author" content="Git for Humans" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://people.well.com/user/scott/git-guide.html" />
<!-- Open Graph (Facebook, LinkedIn, Slack previews) -->
<meta property="og:type" content="website" />
<meta property="og:title" content="Git & GitHub: The Essential Field Guide" />
<meta property="og:description" content="Comprehensive Git and GitHub reference with real-world analogies, command examples, and a quick-reference cheat sheet. Perfect for developers at every level." />
<meta property="og:url" content="https://people.well.com/user/scott/git-guide.html" />
<meta property="og:site_name" content="Git for Humans" />
<meta property="og:locale" content="en_US" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Git & GitHub: The Essential Field Guide" />
<meta name="twitter:description" content="Comprehensive Git and GitHub reference with real-world analogies, command examples, and a quick-reference cheat sheet." />
<!-- Structured Data (JSON-LD) -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Git & GitHub: The Essential Field Guide",
"description": "A comprehensive Git and GitHub reference covering cloning, branching, merging, pull requests, stash, revert, reset, and tags with real-world examples.",
"keywords": "git, github, version control, branching, merging, pull request",
"author": { "@type": "Organization", "name": "Git for Humans" },
"educationalLevel": "Beginner to Intermediate",
"audience": { "@type": "Audience", "audienceType": "Developers" }
}
</script>
<style>
/* ── Design Tokens ── */
:root {
--bg: #0f1117;
--surface: #1a1d27;
--surface2: #22263a;
--border: #2e3350;
--text: #e2e8f0;
--muted: #7c86a2;
--accent: #7c6af7;
--accent-dim: #3d3570;
--green: #3ecf8e;
--green-dim: #1a4a35;
--orange: #f97316;
--orange-dim: #4a2a10;
--red: #f87171;
--red-dim: #4a1a1a;
--blue: #60a5fa;
--blue-dim: #1a2f4a;
--yellow: #fbbf24;
--yellow-dim: #4a380a;
--radius: 12px;
--radius-sm: 6px;
--font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
--font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--font-body);
line-height: 1.7;
min-height: 100vh;
}
/* ── Progress Bar ── */
#progress-bar {
position: fixed;
top: 0; left: 0;
height: 3px;
width: 0%;
background: linear-gradient(90deg, var(--accent), var(--green));
z-index: 1000;
transition: width 0.1s linear;
}
/* ── Layout ── */
.layout {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.body-area {
display: grid;
grid-template-columns: 260px 1fr;
flex: 1;
}
/* ── Header ── */
header {
grid-column: 1 / -1;
padding: 3rem 2rem 2rem;
text-align: center;
background: linear-gradient(160deg, #1a1d27 0%, #0f1117 100%);
border-bottom: 1px solid var(--border);
position: relative;
overflow: hidden;
}
header::before {
content: '';
position: absolute;
top: -60px; left: 50%;
transform: translateX(-50%);
width: 500px; height: 200px;
background: radial-gradient(ellipse, rgba(124,106,247,0.15) 0%, transparent 70%);
pointer-events: none;
}
.hero-badge {
display: inline-flex;
align-items: center;
gap: 6px;
background: var(--accent-dim);
color: var(--accent);
border: 1px solid var(--accent);
border-radius: 100px;
padding: 4px 14px;
font-size: 0.78rem;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
margin-bottom: 1rem;
}
header h1 {
font-size: clamp(1.8rem, 4vw, 2.8rem);
font-weight: 800;
letter-spacing: -0.03em;
background: linear-gradient(135deg, #fff 30%, var(--accent));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 0.75rem;
}
header p {
color: var(--muted);
max-width: 560px;
margin: 0 auto;
font-size: 1.05rem;
}
/* ── Sidebar Nav ── */
nav {
position: sticky;
top: 0;
height: 100vh;
overflow-y: auto;
padding: 2rem 1rem;
border-right: 1px solid var(--border);
background: var(--surface);
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
}
nav::-webkit-scrollbar { width: 4px; }
nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.nav-section-label {
font-size: 0.68rem;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--muted);
padding: 0.75rem 0.5rem 0.3rem;
margin-top: 0.5rem;
}
nav a {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border-radius: var(--radius-sm);
color: var(--muted);
text-decoration: none;
font-size: 0.87rem;
font-weight: 500;
transition: all 0.15s ease;
}
nav a:hover, nav a.active {
background: var(--surface2);
color: var(--text);
}
nav a .dot {
width: 7px; height: 7px;
border-radius: 50%;
flex-shrink: 0;
background: var(--border);
transition: background 0.15s;
}
nav a:hover .dot, nav a.active .dot { background: var(--accent); }
/* ── Main Content ── */
main {
padding: 2.5rem 3rem;
max-width: 900px;
}
/* ── Section Groups ── */
.section-group {
margin-bottom: 3.5rem;
}
.section-group-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--border);
}
.section-icon {
width: 40px; height: 40px;
border-radius: var(--radius-sm);
display: flex; align-items: center; justify-content: center;
font-size: 1.2rem;
flex-shrink: 0;
}
.section-group-header h2 {
font-size: 1.25rem;
font-weight: 700;
letter-spacing: -0.02em;
}
.section-group-header p {
font-size: 0.85rem;
color: var(--muted);
margin-top: 2px;
}
/* ── Command Cards ── */
.command-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
margin-bottom: 1.25rem;
overflow: hidden;
transition: border-color 0.2s ease, transform 0.2s ease;
}
.command-card:hover {
border-color: var(--accent-dim);
transform: translateY(-1px);
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.25rem;
cursor: pointer;
user-select: none;
gap: 1rem;
}
.card-header-left {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.cmd-chip {
font-family: var(--font-mono);
font-size: 0.88rem;
font-weight: 600;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 3px 10px;
color: var(--green);
white-space: nowrap;
flex-shrink: 0;
}
.card-title {
font-size: 0.95rem;
font-weight: 600;
color: var(--text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.card-subtitle {
font-size: 0.8rem;
color: var(--muted);
margin-top: 1px;
}
.chevron {
color: var(--muted);
font-size: 0.75rem;
transition: transform 0.25s ease;
flex-shrink: 0;
}
.command-card.open .chevron { transform: rotate(180deg); }
.card-body {
display: none;
padding: 0 1.25rem 1.25rem;
border-top: 1px solid var(--border);
}
.command-card.open .card-body { display: block; }
/* ── Explainer ── */
.explainer {
margin: 1rem 0;
font-size: 0.95rem;
color: var(--text);
line-height: 1.8;
}
.analogy {
display: flex;
gap: 10px;
background: rgba(124,106,247,0.08);
border-left: 3px solid var(--accent);
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
padding: 0.75rem 1rem;
margin: 1rem 0;
font-size: 0.9rem;
color: var(--text);
}
.analogy-icon { flex-shrink: 0; font-size: 1.1rem; }
/* ── Syntax Blocks ── */
.code-block {
background: #0a0c14;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 1rem 1.25rem;
margin: 0.75rem 0;
overflow-x: auto;
}
.code-block code {
font-family: var(--font-mono);
font-size: 0.87rem;
line-height: 1.9;
display: block;
white-space: pre;
}
.code-block .prompt { color: var(--green); user-select: none; }
.code-block .cmd { color: #c4b5fd; }
.code-block .arg { color: var(--blue); }
.code-block .flag { color: var(--orange); }
.code-block .str { color: var(--yellow); }
.code-block .cmt { color: var(--muted); font-style: italic; }
.code-block .out { color: var(--muted); }
/* ── Examples ── */
.examples-label {
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--muted);
margin: 1.25rem 0 0.5rem;
}
.example-item {
display: grid;
grid-template-columns: auto 1fr;
gap: 8px 12px;
align-items: start;
margin-bottom: 0.75rem;
}
.example-num {
background: var(--accent-dim);
color: var(--accent);
border-radius: 50%;
width: 20px; height: 20px;
font-size: 0.7rem;
font-weight: 700;
display: flex; align-items: center; justify-content: center;
flex-shrink: 0;
margin-top: 3px;
}
.example-text { font-size: 0.88rem; color: var(--text); }
.example-text strong { color: var(--yellow); }
/* ── Warning/Tip Callouts ── */
.callout {
display: flex;
gap: 10px;
border-radius: var(--radius-sm);
padding: 0.75rem 1rem;
margin: 1rem 0;
font-size: 0.87rem;
line-height: 1.6;
}
.callout-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.callout.tip { background: rgba(62,207,142,0.08); border: 1px solid rgba(62,207,142,0.25); color: #a7f3d0; }
.callout.warn { background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.25); color: #fed7aa; }
.callout.info { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.25); color: #bfdbfe; }
/* ── Color themes per section ── */
.theme-start .section-icon { background: var(--accent-dim); color: var(--accent); }
.theme-change .section-icon { background: var(--green-dim); color: var(--green); }
.theme-branch .section-icon { background: var(--blue-dim); color: var(--blue); }
.theme-remote .section-icon { background: var(--orange-dim); color: var(--orange); }
.theme-collab .section-icon { background: var(--yellow-dim); color: var(--yellow); }
.theme-fix .section-icon { background: var(--red-dim); color: var(--red); }
.theme-start .section-group-header h2 { color: var(--accent); }
.theme-change .section-group-header h2 { color: var(--green); }
.theme-branch .section-group-header h2 { color: var(--blue); }
.theme-remote .section-group-header h2 { color: var(--orange); }
.theme-collab .section-group-header h2 { color: var(--yellow); }
.theme-fix .section-group-header h2 { color: var(--red); }
/* ── Footer ── */
footer {
text-align: center;
padding: 2rem;
border-top: 1px solid var(--border);
color: var(--muted);
font-size: 0.82rem;
}
/* ── Cheatsheet Table ── */
.cheat-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 10px;
margin-top: 1rem;
}
.cheat-item {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 10px 12px;
}
.cheat-cmd {
font-family: var(--font-mono);
font-size: 0.8rem;
color: var(--green);
font-weight: 600;
margin-bottom: 3px;
}
.cheat-desc {
font-size: 0.77rem;
color: var(--muted);
}
/* ── Responsive ── */
@media (max-width: 768px) {
.body-area {
grid-template-columns: 1fr;
}
nav {
position: static;
height: auto;
border-right: none;
border-bottom: 1px solid var(--border);
display: flex;
flex-wrap: wrap;
gap: 4px;
padding: 1rem;
}
.nav-section-label { display: none; }
nav a { font-size: 0.75rem; padding: 5px 8px; }
main { padding: 1.5rem 1.25rem; }
header { padding: 2rem 1.25rem 1.5rem; }
}
/* ── Animations ── */
@keyframes fadeUp {
from { opacity: 0; transform: translateY(16px); }
to { opacity: 1; transform: translateY(0); }
}
.section-group {
animation: fadeUp 0.4s ease both;
}
.section-group:nth-child(1) { animation-delay: 0.05s; }
.section-group:nth-child(2) { animation-delay: 0.10s; }
.section-group:nth-child(3) { animation-delay: 0.15s; }
.section-group:nth-child(4) { animation-delay: 0.20s; }
.section-group:nth-child(5) { animation-delay: 0.25s; }
.section-group:nth-child(6) { animation-delay: 0.30s; }
.section-group:nth-child(7) { animation-delay: 0.35s; }
</style>
</head>
<body>
<div id="progress-bar"></div>
<div class="layout">
<!-- ══ HEADER ══ -->
<header>
<div class="hero-badge">🧭 Field Guide</div>
<h1>Git & GitHub: The Essential Commands</h1>
<p>Everything you need to contribute confidently to open-source projects and keep your repos healthy. Explained in plain English.</p>
</header>
<!-- ══ BODY AREA (nav + main) ══ -->
<div class="body-area">
<!-- ══ SIDEBAR NAV ══ -->
<nav id="sidebar-nav">
<div class="nav-section-label">Getting Started</div>
<a href="#section-start"><span class="dot"></span> Setup & Cloning</a>
<a href="#section-status"><span class="dot"></span> Checking Status</a>
<div class="nav-section-label">Making Changes</div>
<a href="#section-change"><span class="dot"></span> Staging & Committing</a>
<a href="#section-log"><span class="dot"></span> Viewing History</a>
<div class="nav-section-label">Branches</div>
<a href="#section-branch"><span class="dot"></span> Creating & Switching</a>
<a href="#section-merge"><span class="dot"></span> Merging</a>
<div class="nav-section-label">Syncing with GitHub</div>
<a href="#section-remote"><span class="dot"></span> Push, Pull & Fetch</a>
<a href="#section-pr"><span class="dot"></span> Pull Requests</a>
<div class="nav-section-label">Fixing Mistakes</div>
<a href="#section-fix"><span class="dot"></span> Undo & Stash</a>
<div class="nav-section-label">Quick Reference</div>
<a href="#section-cheat"><span class="dot"></span> Cheat Sheet</a>
</nav>
<!-- ══ MAIN ══ -->
<main>
<!-- ─── SECTION: Getting Started ─── -->
<div class="section-group theme-start" id="section-start">
<div class="section-group-header">
<div class="section-icon">🚀</div>
<div>
<h2>Setup & Cloning</h2>
<p>Getting Git ready and grabbing your first repository</p>
</div>
</div>
<!-- git config -->
<div class="command-card" id="cmd-config">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git config</span>
<div>
<div class="card-title">Set your identity</div>
<div class="card-subtitle">Tell Git who you are before your first commit</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
Before you do anything, Git needs to know your name and email so it can stamp your work with your identity. Every commit you create will carry this information. It's just like signing your name on a document.
</div>
<div class="analogy">
<span class="analogy-icon">📝</span>
<span>Think of it like filling out your name badge at a conference. You only do it once, and then everyone knows who you are at every event (commit) you attend.</span>
</div>
<div class="code-block"><code><span class="prompt">$ </span><span class="cmd">git config</span> <span class="flag">--global</span> <span class="arg">user.name</span> <span class="str">"Your Name"</span>
<span class="prompt">$ </span><span class="cmd">git config</span> <span class="flag">--global</span> <span class="arg">user.email</span> <span class="str">"you@example.com"</span>
<span class="cmt"># Check what you set</span>
<span class="prompt">$ </span><span class="cmd">git config</span> <span class="flag">--list</span></code></div>
<div class="callout tip">
<span class="callout-icon">✔️</span>
<span>Use the same email address as your GitHub account. That's how GitHub links your commits to your profile and contribution graph.</span>
</div>
</div>
</div>
<!-- git init -->
<div class="command-card" id="cmd-init">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git init</span>
<div>
<div class="card-title">Create a new repository</div>
<div class="card-subtitle">Turn any folder into a Git-tracked project from scratch</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
<code>git init</code> sets up a brand-new Git repository inside your current folder. It creates a hidden <code>.git</code> folder that Git uses to track every change you ever make.
</div>
<div class="analogy">
<span class="analogy-icon">📂</span>
<span>Imagine opening a fresh binder and putting a set of divider tabs in it. Nothing is filed yet, but the binder is ready to track everything you put in it going forward.</span>
</div>
<div class="code-block"><code><span class="cmt"># Go into your project folder first</span>
<span class="prompt">$ </span><span class="cmd">cd</span> <span class="arg">my-project</span>
<span class="prompt">$ </span><span class="cmd">git init</span>
<span class="out">Initialized empty Git repository in /my-project/.git/</span></code></div>
<div class="examples-label">Real-world scenarios</div>
<div class="example-item">
<div class="example-num">1</div>
<div class="example-text">You just started a new website and want to start tracking changes: <strong>cd website-folder && git init</strong></div>
</div>
<div class="example-item">
<div class="example-num">2</div>
<div class="example-text">You finished prototyping a script and now want a proper history before sharing it with a teammate.</div>
</div>
</div>
</div>
<!-- git clone -->
<div class="command-card open" id="cmd-clone">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git clone</span>
<div>
<div class="card-title">Download an existing repository</div>
<div class="card-subtitle">Copy a GitHub project to your computer</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
<code>git clone</code> makes a full copy of a repository from GitHub (or any remote) onto your machine — including all files, history, and branches. It's the standard first step for contributing to an existing project.
</div>
<div class="analogy">
<span class="analogy-icon">📦</span>
<span>It's like downloading a zip of the project, except you also get the complete filing cabinet of every change ever made, and a live connection back to the original.</span>
</div>
<div class="code-block"><code><span class="cmt"># Clone into a new folder named after the repo</span>
<span class="prompt">$ </span><span class="cmd">git clone</span> <span class="arg">https://github.com/user/repo-name.git</span>
<span class="cmt"># Clone into a folder with a custom name</span>
<span class="prompt">$ </span><span class="cmd">git clone</span> <span class="arg">https://github.com/user/repo-name.git</span> <span class="str">my-folder</span></code></div>
<div class="examples-label">Real-world scenarios</div>
<div class="example-item">
<div class="example-num">1</div>
<div class="example-text">You found an open-source tool on GitHub and want to run it locally or fix a bug: clone it, then work in your copy.</div>
</div>
<div class="example-item">
<div class="example-num">2</div>
<div class="example-text">A coworker shared a repo link and you need to get the project running on your laptop before tomorrow's meeting.</div>
</div>
</div>
</div>
</div>
<!-- ─── SECTION: Status ─── -->
<div class="section-group theme-start" id="section-status">
<div class="section-group-header">
<div class="section-icon">🔍</div>
<div>
<h2>Checking the Status</h2>
<p>Always know what's going on before you do anything</p>
</div>
</div>
<!-- git status -->
<div class="command-card" id="cmd-status">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git status</span>
<div>
<div class="card-title">See what's changed</div>
<div class="card-subtitle">Your most-used command; Run it often</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
<code>git status</code> gives you a snapshot of your current situation: which files are new, which have been modified, which are staged and ready to commit, and what branch you're on. It never changes anything, it only reports.
</div>
<div class="analogy">
<span class="analogy-icon">📋</span>
<span>Think of it as glancing at your desk before leaving the office. You're checking: what's still out? what got filed? what needs to be dealt with before you go?</span>
</div>
<div class="code-block"><code><span class="prompt">$ </span><span class="cmd">git status</span>
<span class="out">On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
style.css</span></code></div>
<div class="callout tip">
<span class="callout-icon">💡</span>
<span>Make <code>git status</code> a reflex. Run it before staging, before committing, before switching branches, it takes half a second and prevents most beginner mistakes.</span>
</div>
</div>
</div>
<!-- git diff -->
<div class="command-card" id="cmd-diff">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git diff</span>
<div>
<div class="card-title">See exactly what changed</div>
<div class="card-subtitle">Line-by-line comparison of your edits</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
While <code>git status</code> tells you <em>which</em> files changed, <code>git diff</code> shows you precisely <em>what</em> changed inside them, line by line. Lines starting with <code>+</code> were added, lines with <code>-</code> were removed.
</div>
<div class="code-block"><code><span class="cmt"># See all unstaged changes</span>
<span class="prompt">$ </span><span class="cmd">git diff</span>
<span class="cmt"># See changes already staged for commit</span>
<span class="prompt">$ </span><span class="cmd">git diff</span> <span class="flag">--staged</span>
<span class="cmt"># Compare two branches</span>
<span class="prompt">$ </span><span class="cmd">git diff</span> <span class="arg">main feature-branch</span></code></div>
<div class="examples-label">Real-world scenarios</div>
<div class="example-item">
<div class="example-num">1</div>
<div class="example-text">You edited a config file and can't remember what you changed, <strong>git diff config.yaml</strong> shows the exact lines.</div>
</div>
<div class="example-item">
<div class="example-num">2</div>
<div class="example-text">Before committing, run <strong>git diff --staged</strong> to review everything one last time so your commit message can be accurate.</div>
</div>
</div>
</div>
</div>
<!-- ─── SECTION: Staging & Committing ─── -->
<div class="section-group theme-change" id="section-change">
<div class="section-group-header">
<div class="section-icon">✏️</div>
<div>
<h2>Staging & Committing</h2>
<p>Saving your work to Git's history; The core workflow</p>
</div>
</div>
<!-- git add -->
<div class="command-card" id="cmd-add">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git add</span>
<div>
<div class="card-title">Stage files for a commit</div>
<div class="card-subtitle">Choose what goes into your next save point</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
Before Git saves anything, you have to deliberately choose which changes to include. <code>git add</code> moves files into a "staging area", a draft zone where you assemble the perfect commit before locking it in.
</div>
<div class="analogy">
<span class="analogy-icon">🛍️</span>
<span>Picture a shopping cart. <code>git add</code> puts items in the cart. You haven't bought anything yet, so you can still swap things out. <code>git commit</code> (next) is when you actually check out.</span>
</div>
<div class="code-block"><code><span class="cmt"># Stage a specific file</span>
<span class="prompt">$ </span><span class="cmd">git add</span> <span class="arg">index.html</span>
<span class="cmt"># Stage all changed files at once</span>
<span class="prompt">$ </span><span class="cmd">git add</span> <span class="flag">.</span>
<span class="cmt"># Stage all .js files</span>
<span class="prompt">$ </span><span class="cmd">git add</span> <span class="arg">*.js</span>
<span class="cmt"># Interactively choose which parts of a file to stage</span>
<span class="prompt">$ </span><span class="cmd">git add</span> <span class="flag">-p</span> <span class="arg">script.js</span></code></div>
<div class="callout warn">
<span class="callout-icon">⚠️</span>
<span><code>git add .</code> stages everything in the folder. That's usually fine, but watch out for accidentally staging temporary files, passwords, or large binaries. A <code>.gitignore</code> file (below) prevents those from being tracked.</span>
</div>
</div>
</div>
<!-- git commit -->
<div class="command-card" id="cmd-commit">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git commit</span>
<div>
<div class="card-title">Save a snapshot of your work</div>
<div class="card-subtitle">Create a permanent entry in your project's history</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
A commit is a permanent snapshot of your staged changes, stamped with your name, the date, and a message you write. Every commit is forever preserved in the project history.
</div>
<div class="analogy">
<span class="analogy-icon">📸</span>
<span>A commit is like taking a photo of your work. No matter how much things change afterward, you can always pull out that photo and see exactly what it looked like at that moment.</span>
</div>
<div class="code-block"><code><span class="cmt"># The standard commit with a message</span>
<span class="prompt">$ </span><span class="cmd">git commit</span> <span class="flag">-m</span> <span class="str">"Add navigation menu to header"</span>
<span class="cmt"># Stage all tracked files and commit in one step</span>
<span class="prompt">$ </span><span class="cmd">git commit</span> <span class="flag">-am</span> <span class="str">"Fix typo in homepage copy"</span></code></div>
<div class="examples-label">Writing a good commit message</div>
<div class="example-item">
<div class="example-num">✔</div>
<div class="example-text"><strong>"Add user login form with email validation"</strong>. Clear, describes what changed and why</div>
</div>
<div class="example-item">
<div class="example-num">✘</div>
<div class="example-text"><strong>"stuff"</strong> or <strong>"changes"</strong> is Useless in 6 months when you're trying to find a bug</div>
</div>
<div class="callout tip">
<span class="callout-icon">💡</span>
<span>Aim to commit one logical change at a time. Small, focused commits are much easier to review, revert, or understand later.</span>
</div>
</div>
</div>
<!-- .gitignore -->
<div class="command-card" id="cmd-gitignore">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">.gitignore</span>
<div>
<div class="card-title">Tell Git what to ignore</div>
<div class="card-subtitle">Keep junk, secrets, and build artifacts out of your repo</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
A <code>.gitignore</code> file is a plain text list of file patterns you never want Git to track. It lives in your project root and prevents things like passwords, auto-generated folders, or your personal editor settings from accidentally ending up in commits.
</div>
<div class="analogy">
<span class="analogy-icon">🚫</span>
<span>It's like telling the movers "don't pack the junk drawer." You're setting rules upfront so those things never make it into the truck.</span>
</div>
<div class="code-block"><code><span class="cmt"># Example .gitignore file</span>
<span class="out">node_modules/ </span><span class="cmt"># JS dependencies (huge, auto-downloaded)</span>
<span class="out">.env </span><span class="cmt"># Environment variables / API keys</span>
<span class="out">*.log </span><span class="cmt"># Any log file</span>
<span class="out">dist/ </span><span class="cmt"># Build output</span>
<span class="out">.DS_Store </span><span class="cmt"># macOS folder metadata</span></code></div>
<div class="callout info">
<span class="callout-icon">🔗</span>
<span>Visit <strong>gitignore.io</strong> and type in your language or framework to instantly generate a solid <code>.gitignore</code> file.</span>
</div>
</div>
</div>
</div>
<!-- ─── SECTION: Log ─── -->
<div class="section-group theme-change" id="section-log">
<div class="section-group-header">
<div class="section-icon">📜</div>
<div>
<h2>Viewing History</h2>
<p>Explore what happened and when</p>
</div>
</div>
<!-- git log -->
<div class="command-card" id="cmd-log">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git log</span>
<div>
<div class="card-title">Browse commit history</div>
<div class="card-subtitle">See every saved snapshot in order</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
<code>git log</code> lists every commit ever made to the current branch, with the author, date, and message for each. It's the project's complete diary.
</div>
<div class="code-block"><code><span class="cmt"># Full log</span>
<span class="prompt">$ </span><span class="cmd">git log</span>
<span class="cmt"># Compact one-liner format (highly recommended)</span>
<span class="prompt">$ </span><span class="cmd">git log</span> <span class="flag">--oneline</span>
<span class="out">a3f21bc Fix broken link in footer
7c4d9a1 Add contact page
2e18f00 Initial commit</span>
<span class="cmt"># Visual branch graph</span>
<span class="prompt">$ </span><span class="cmd">git log</span> <span class="flag">--oneline --graph --all</span>
<span class="cmt"># Show last 5 commits only</span>
<span class="prompt">$ </span><span class="cmd">git log</span> <span class="flag">-5</span></code></div>
<div class="callout tip">
<span class="callout-icon">💡</span>
<span>Press <code>q</code> to quit the log view. Use the arrow keys or <code>spacebar</code> to scroll through long histories.</span>
</div>
</div>
</div>
</div>
<!-- ─── SECTION: Branches ─── -->
<div class="section-group theme-branch" id="section-branch">
<div class="section-group-header">
<div class="section-icon">🌳</div>
<div>
<h2>Creating & Switching Branches</h2>
<p>Work on features and fixes without disturbing the main codebase</p>
</div>
</div>
<!-- git branch -->
<div class="command-card" id="cmd-branch">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git branch</span>
<div>
<div class="card-title">List & manage branches</div>
<div class="card-subtitle">See all branches or create/delete them</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
A branch is a separate, parallel version of your project. You create a branch to work on something new without risking the stable main code. When your work is done and tested, you merge it back in.
</div>
<div class="analogy">
<span class="analogy-icon">🧪</span>
<span>Think of the main branch as the live product, and a feature branch as a lab bench where you experiment freely. You only move experiments to the live shelf once they're proven to work.</span>
</div>
<div class="code-block"><code><span class="cmt"># List all local branches (* marks your current branch)</span>
<span class="prompt">$ </span><span class="cmd">git branch</span>
<span class="out">* main
feature/login-page</span>
<span class="cmt"># List all branches including remote ones</span>
<span class="prompt">$ </span><span class="cmd">git branch</span> <span class="flag">-a</span>
<span class="cmt"># Delete a branch (won't delete unmerged work)</span>
<span class="prompt">$ </span><span class="cmd">git branch</span> <span class="flag">-d</span> <span class="arg">feature/login-page</span></code></div>
</div>
</div>
<!-- git switch / checkout -b -->
<div class="command-card" id="cmd-switch">
<div class="card-header" onclick="toggleCard(this)">
<div class="card-header-left">
<span class="cmd-chip">git switch</span>
<div>
<div class="card-title">Create & switch branches</div>
<div class="card-subtitle">Move between branches or start a new one</div>
</div>
</div>
<span class="chevron">▼</span>
</div>
<div class="card-body">
<div class="explainer">
<code>git switch</code> moves you to a different branch. Add <code>-c</code> to create a new branch at the same time. Your files instantly reflect that branch's state.
</div>