-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-cheatsheet.html
More file actions
711 lines (662 loc) · 66.6 KB
/
Copy pathgit-cheatsheet.html
File metadata and controls
711 lines (662 loc) · 66.6 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git Cheatsheet — 60+ Commands & Examples | FreeDevTool</title>
<meta name="description" content="Free git commands cheatsheet — 60+ commands, real examples, 10-step learning path. Branching, rebasing, stashing, conflict resolution.">
<meta name="robots" content="index, follow">
<meta name="author" content="Anees Ur Rehman">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","datePublished":"2026-05-02","dateModified":"2026-05-19","inLanguage":"en-US","isPartOf":{"@type":"WebSite","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Person","name":"Anees Ur Rehman","url":"https://freedevtool.org/about","jobTitle":"Full-stack developer","worksFor":{"@type":"Organization","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "How to use the git commands cheatsheet",
"description": "Quickly find any git command with live search, copy-ready examples, and a 10-step learning path for newcomers.",
"step": [
{"@type":"HowToStep","name":"Search by command or task","text":"Type the command (e.g., 'rebase') or task (e.g., 'undo last commit') in the search box. Results filter live."},
{"@type":"HowToStep","name":"Browse by category","text":"Or browse 11 categories: setup, basics, branching, merging, rebasing, stashing, history, undoing, remotes, tags, advanced."},
{"@type":"HowToStep","name":"Copy the example","text":"Click any command to copy its example to clipboard, ready to paste in terminal."},
{"@type":"HowToStep","name":"Follow the learning path","text":"New to git? Follow the 10-step path: init → add → commit → branch → checkout → merge → push → pull → log → reset."}
]
}
</script>
<link rel="canonical" href="https://freedevtool.org/git-cheatsheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap">
<link rel="preload" href="style.css?v=20260502-cards" as="style">
<link rel="stylesheet" href="style.css?v=20260502-cards">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/favicon.svg">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="FreeDevTool — 50+ free, fast, privacy-first developer tools">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<meta name="twitter:title" content="Git Commands Cheatsheet — 60+ Commands & Examples">
<meta name="twitter:description" content="60+ git commands organized in 11 categories with copy-ready examples. Live search, 10-step learning path, and a deep guide to git internals.">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3L0CMH3X36"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-3L0CMH3X36');</script>
<meta property="og:title" content="Git Commands Cheatsheet — 60+ Commands Reference">
<meta property="og:description" content="Searchable git cheatsheet with examples, categories, and a 10-step learning path for newcomers.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://freedevtool.org/git-cheatsheet">
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebApplication","name":"Git Commands Cheatsheet","url":"https://freedevtool.org/git-cheatsheet","description":"Searchable reference of 60+ git commands with examples and a learning path.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"}}
</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between git reset and git revert?","acceptedAnswer":{"@type":"Answer","text":"git reset rewrites history by moving the branch pointer backward; git revert creates a new commit that undoes the changes of a previous commit without altering history. Use revert on shared branches — reset is only safe on private branches nobody else has pulled."}},{"@type":"Question","name":"When should I use git rebase instead of merge?","acceptedAnswer":{"@type":"Answer","text":"Use rebase when you want a linear history on your feature branch before merging. Use merge when you want to preserve the exact history of branches, including the merge point. The golden rule: never rebase commits that exist outside your local repo and that other people may have based work on."}},{"@type":"Question","name":"How do I undo the last commit in git?","acceptedAnswer":{"@type":"Answer","text":"If you haven't pushed yet: git reset --soft HEAD~1 keeps your changes staged, git reset --mixed HEAD~1 keeps them unstaged, git reset --hard HEAD~1 discards them entirely. If you've already pushed: use git revert HEAD to create an inverse commit that's safe on shared branches."}},{"@type":"Question","name":"What does git stash do?","acceptedAnswer":{"@type":"Answer","text":"git stash saves your uncommitted changes (tracked files) onto a stack and reverts your working directory to HEAD. Useful when you need to quickly switch branches without committing half-finished work. Restore with git stash pop (removes from stack) or git stash apply (keeps it)."}},{"@type":"Question","name":"How do I resolve a merge conflict?","acceptedAnswer":{"@type":"Answer","text":"When git reports a conflict, open the conflicted files — you'll see markers <<<<<<< HEAD, =======, and >>>>>>> branch-name surrounding the conflicting regions. Edit the file to the desired final state (removing the markers), then git add the file and git commit to complete the merge. You can also run git merge --abort to cancel the merge entirely."}},{"@type":"Question","name":"How do I undo my last git commit?","acceptedAnswer":{"@type":"Answer","text":"Three options: git reset --soft HEAD~1 removes the commit, keeps changes staged; git reset --mixed HEAD~1 (default) keeps changes unstaged; git reset --hard HEAD~1 discards changes entirely. Never use --hard on commits you have pushed; use git revert instead."}},{"@type":"Question","name":"What is the difference between git merge and git rebase?","acceptedAnswer":{"@type":"Answer","text":"git merge preserves the exact branch history with a merge commit — branches show as separate streams that joined. git rebase rewrites your commits on top of the target branch — history looks linear. Never rebase shared branches; rebase only local work."}},{"@type":"Question","name":"What is the difference between git fetch and git pull?","acceptedAnswer":{"@type":"Answer","text":"git fetch downloads the latest commits from the remote without changing your local branches. git pull is git fetch followed by git merge (or rebase with --rebase). Use fetch + manual merge for more control; use pull for fast updates."}}]}
</script>
<style>
.gc-search{width:100%;padding:14px 18px;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);font-family:var(--mono);font-size:15px;margin-bottom:20px}
.gc-search:focus{border-color:var(--accent);outline:none;box-shadow:0 0 0 3px rgba(0,208,132,.08)}
.gc-path{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:18px;margin-bottom:24px}
.gc-path h3{margin:0 0 14px;font-size:13px;color:var(--accent);font-family:var(--mono);text-transform:uppercase;letter-spacing:1px}
.gc-steps{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:10px}
.gc-step{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);padding:10px 12px;font-family:var(--mono);font-size:12px;color:var(--text2);display:flex;gap:8px;align-items:flex-start}
.gc-step-n{color:var(--accent);font-weight:600;flex-shrink:0}
.gc-cat{margin-bottom:28px}
.gc-cat h3{margin:0 0 12px;font-size:11px;color:var(--accent);font-family:var(--mono);text-transform:uppercase;letter-spacing:1px;padding-bottom:6px;border-bottom:1px solid var(--border)}
.gc-cmd{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;margin-bottom:8px}
.gc-cmd-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:6px}
.gc-cmd-code{font-family:var(--mono);font-size:13px;color:var(--text);background:var(--bg2);padding:6px 10px;border-radius:4px;flex:1;word-break:break-word;white-space:pre-wrap}
.gc-cmd-copy{padding:5px 10px;font-size:11px;font-family:var(--mono);background:var(--bg4);border:1px solid var(--border);border-radius:4px;color:var(--text2);cursor:pointer;flex-shrink:0}
.gc-cmd-copy:hover{border-color:var(--accent);color:var(--accent)}
.gc-cmd-desc{font-size:13px;color:var(--text2);line-height:1.5;margin:6px 0 0}
.gc-cmd-example{font-family:var(--mono);font-size:11px;color:var(--text3);margin-top:6px;padding:6px 10px;background:var(--bg2);border-radius:4px;white-space:pre-wrap;word-break:break-word}
.gc-empty{color:var(--text3);font-family:var(--mono);font-size:13px;padding:20px;text-align:center}
.gc-content{margin-top:32px;color:var(--text2);line-height:1.7;font-size:14px}
.gc-content h2{color:var(--text);font-size:20px;margin:24px 0 10px}
.gc-content h3{color:var(--text);font-size:15px;margin:18px 0 8px}
.gc-content p{margin:0 0 12px}
.gc-content code{font-family:var(--mono);background:var(--bg2);padding:2px 6px;border-radius:3px;font-size:12px;color:var(--accent)}
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://freedevtool.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "All Tools",
"item": "https://freedevtool.org/all-tools"
},
{
"@type": "ListItem",
"position": 3,
"name": "Git Commands Cheatsheet",
"item": "https://freedevtool.org/git-cheatsheet"
}
]
}
</script>
<script src="/ga4-events.js" defer></script>
</head>
<body>
<nav>
<a class="nav-logo" href="/" aria-label="FreeDevTool home"><svg class="logo-mark" width="22" height="22" viewBox="0 0 24 24" aria-hidden="true" fill="none"><rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" opacity=".12"/><path d="M9.5 8.5L6 12l3.5 3.5M14.5 8.5L18 12l-3.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>FreeDevTool</a>
<div class="nav-links">
<div class="nav-dropdown" id="tools-dropdown">
<a href="all-tools" onclick="event.preventDefault();this.parentElement.classList.toggle('open')" aria-haspopup="true">Tools <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></a>
<div class="nav-dropdown-menu">
<a href="encoding-tools">
<div class="dd-icon">b64</div>
<div class="dd-info"><div class="dd-name">Encoding & Conversion</div><div class="dd-count">11 tools · Base64, YAML, px→rem</div></div>
</a>
<a href="generation-tools">
<div class="dd-icon">{ }</div>
<div class="dd-info"><div class="dd-name">Generation & Formatting</div><div class="dd-count">16 tools · JSON, SQL, gradients</div></div>
</a>
<a href="security-tools">
<div class="dd-icon">#</div>
<div class="dd-info"><div class="dd-name">Security & Hashing</div><div class="dd-count">3 tools · JWT, MD5, SHA</div></div>
</a>
<a href="text-tools">
<div class="dd-icon">.*</div>
<div class="dd-info"><div class="dd-name">Code & Text Tools</div><div class="dd-count">9 tools · Regex, diff, tokens</div></div>
</a>
<a href="devops-tools">
<div class="dd-icon">JS</div>
<div class="dd-info"><div class="dd-name">Optimization & DevOps</div><div class="dd-count">7 tools · Minifiers, cURL, git</div></div>
</a>
<a href="network-tools">
<div class="dd-icon">IP</div>
<div class="dd-info"><div class="dd-name">Network & Time</div><div class="dd-count">4 tools · IP, DNS, timestamps</div></div>
</a>
<a href="seo-tools">
<div class="dd-icon">SEO</div>
<div class="dd-info"><div class="dd-name">SEO & Meta Tools</div><div class="dd-count">3 tools · OG, meta, slug</div></div>
</a>
<div class="nav-dropdown-divider"></div>
<a class="dd-all" href="all-tools">
<div class="dd-icon">All</div>
<div class="dd-info"><div class="dd-name">Browse all 50 tools</div><div class="dd-count">Searchable catalog & categories</div></div>
</a>
</div>
</div>
<a href="/guides">Guides</a>
<a href="about">About</a>
<a href="privacy">Privacy</a>
</div>
</nav>
<div class="wrapper">
<section class="tool-header">
<a class="tool-back" href="/" aria-label="Back to home">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>
Back
</a>
<span class="tool-badge">Reference</span>
<h1>Git Commands Cheatsheet</h1>
<p>A complete git commands cheatsheet with more than 60 commands organized into 11 practical categories. Every entry includes a concise description, a real-world example, and a one-click copy button. The live search at the top filters across names, descriptions, and examples so you can jump directly to what you need. Whether you're setting up your first repository, untangling a messy history, rebasing a feature branch, or managing submodules on a large monorepo, this page is designed to be the single page you keep open in a tab. Skim the 10-step learning path if you're new.</p>
<div class="last-updated">Last updated: May 2026 · Written by <a href="/about">Anees Ur Rehman</a>, full-stack developer</div>
</section>
<div class="tool-card">
<div class="card-dots"><span></span><span></span><span></span></div>
<div class="tool-body">
<input type="text" class="gc-search" id="gc-search" placeholder="Filter commands... (e.g. 'branch', 'undo', 'remote')">
<div class="gc-path">
<h3>10-Step Learning Path for Newcomers</h3>
<div class="gc-steps">
<div class="gc-step"><span class="gc-step-n">1.</span><span>Configure your name and email with <code>git config</code></span></div>
<div class="gc-step"><span class="gc-step-n">2.</span><span>Create a repo with <code>git init</code> or clone one</span></div>
<div class="gc-step"><span class="gc-step-n">3.</span><span>Check status and diff your changes</span></div>
<div class="gc-step"><span class="gc-step-n">4.</span><span>Stage files with <code>git add</code></span></div>
<div class="gc-step"><span class="gc-step-n">5.</span><span>Commit with a clear message</span></div>
<div class="gc-step"><span class="gc-step-n">6.</span><span>Push and pull from a remote</span></div>
<div class="gc-step"><span class="gc-step-n">7.</span><span>Create and switch branches</span></div>
<div class="gc-step"><span class="gc-step-n">8.</span><span>Merge branches and resolve conflicts</span></div>
<div class="gc-step"><span class="gc-step-n">9.</span><span>Learn to undo safely (reset, revert, reflog)</span></div>
<div class="gc-step"><span class="gc-step-n">10.</span><span>Explore rebase, stash, and tags</span></div>
</div>
</div>
<div id="gc-list"></div>
<div class="gc-empty" id="gc-empty" style="display:none">No commands match your filter.</div>
<div class="gc-content">
<h2>Why learn git deeply?</h2>
<p>Git is the distributed version control system that powers nearly every open-source project, every internal company codebase, and every modern deployment pipeline. It was created by Linus Torvalds in 2005 to manage Linux kernel development after the team lost access to BitKeeper, and its design reflects that origin: it's built to handle thousands of contributors working across disconnected forks with no central authority, and it's ruthlessly fast at operating on full histories of hundreds of thousands of commits. Learning git well is one of the highest-leverage investments a developer can make. Most engineers get by knowing five commands: <code>clone</code>, <code>add</code>, <code>commit</code>, <code>push</code>, and <code>pull</code>. That's enough to function, but it leaves you helpless when anything goes wrong — a bad merge, a lost commit, a branch you can't remember creating. The engineers who can debug git state, cherry-pick fixes across branches, and rewrite history safely are disproportionately valuable on any team.</p>
<h2>The mental model that unlocks git</h2>
<p>Git is not a pile of patches. It's a content-addressable filesystem with a version control interface bolted on top. Every file you commit is stored as a <em>blob</em> identified by a SHA-1 hash of its contents. Every directory snapshot is a <em>tree</em> that references blobs by hash. A <em>commit</em> is an object that references one tree (the state of the whole project), plus its parent commit(s), plus author metadata. A <em>branch</em> is just a movable pointer to a commit — nothing more. A <em>tag</em> is a fixed pointer. Remote-tracking branches like <code>origin/main</code> are pointers that mirror what the remote had at the last fetch. Once this model clicks, everything else follows. <code>git reset</code> moves a branch pointer. <code>git merge</code> creates a new commit with two parents. <code>git rebase</code> rewrites a series of commits so they have different parents. <code>git cherry-pick</code> copies the diff from one commit onto another branch as a new commit with a new hash.</p>
<h2>Staging area: the feature that confuses everyone first</h2>
<p>Unlike Subversion or Mercurial, git has a three-layer structure: your <strong>working directory</strong> (the files on disk), the <strong>index</strong> or <strong>staging area</strong> (a snapshot of what the next commit will contain), and the <strong>repository</strong> (the committed history). You move changes between layers with <code>git add</code> (working → staged), <code>git reset</code> (staged → working), and <code>git commit</code> (staged → committed). The staging area feels like extra friction when you're starting out, but it becomes indispensable when you need to split a messy working directory into several small, focused commits. Use <code>git add -p</code> to stage individual hunks interactively — it's one of the most underused features in git.</p>
<h2>The golden rule of rebasing</h2>
<p>Never rebase commits that exist outside your local repository. When you rebase, you're rewriting history — new commits are created with new SHAs, and the old commits become orphaned. If someone else has already pulled the old commits and based work on them, your rebased history will create a painful divergence that's hard to reconcile. The safe pattern: rebase your local feature branch onto the latest main before opening a PR (so history is linear), but once the PR is under review and other people may have pulled it, prefer merge commits. Some teams adopt a stricter "merge-only" policy on main to avoid any history rewriting in public branches.</p>
<h2>Recovering from mistakes</h2>
<p>Git almost never loses data. Commits that are no longer reachable from any branch or tag stay in the object database for at least 30 days (controlled by <code>gc.reflogExpire</code>) before garbage collection. The <code>git reflog</code> command shows every change to HEAD — every commit, checkout, reset, and merge — giving you a way to recover from almost anything. If you accidentally <code>reset --hard</code> and lose work, run <code>git reflog</code>, find the SHA of the state you want, and <code>git reset --hard <sha></code> back to it. This is one of the most reassuring features in the whole tool, and it's why you should never be afraid to experiment with git commands.</p>
<h2>Branching strategies in practice</h2>
<p>The two dominant strategies are <strong>trunk-based development</strong> (everyone commits to main with short-lived feature branches, protected by CI) and <strong>Git Flow</strong> (long-lived develop and release branches, hotfix branches, and semver tags). Trunk-based suits teams with strong test automation and continuous deployment; Git Flow suits teams shipping versioned software to customers on slower release cadences. GitHub Flow is a lightweight variant — main is always deployable, and every change happens through a feature branch and PR. Pick the simplest model your team's release cadence supports.</p>
<h2>Power commands worth knowing</h2>
<p><code>git bisect</code> performs a binary search through history to find the commit that introduced a bug. You mark a known-good commit and a known-bad commit, then git checks out the middle commit; you test it and mark good or bad; git narrows down, and within <em>log₂(n)</em> steps you've found the culprit. <code>git blame</code> shows who last modified each line of a file — invaluable for archaeology. <code>git log --oneline --graph --all</code> draws an ASCII graph of the full branch topology. <code>git show <sha></code> displays a commit's diff and metadata. <code>git diff --stat</code> summarizes changes across many files. Master these and you can navigate any codebase's history fluently.</p>
<h2>Configuring git for humans</h2>
<p>A few config settings make daily git much nicer. <code>git config --global init.defaultBranch main</code> uses <code>main</code> instead of <code>master</code>. <code>git config --global pull.rebase true</code> rebases instead of merging on pull (avoids noisy merge commits). <code>git config --global core.editor "code --wait"</code> uses VS Code for commit messages. Set up <code>~/.gitignore_global</code> for editor files and OS clutter. Add SSH key authentication to GitHub/GitLab to skip password prompts. Enable commit signing with GPG or SSH to prove commits are yours. These take ten minutes to set up once and save hours over a career.</p>
</div>
</div>
</div>
<div id="toast" style="position:fixed;bottom:30px;left:50%;transform:translateX(-50%);background:var(--accent);color:#000;padding:8px 20px;border-radius:var(--radius);font-size:13px;font-weight:600;opacity:0;transition:opacity .3s;pointer-events:none;z-index:999">Copied!</div>
<p class="aeo-lead" style="font-size:16px;line-height:1.7;color:var(--text);max-width:760px;margin:24px auto 18px;padding:0 4px">
<strong>Git</strong> is the distributed version control system used in every modern dev shop. After 20 years it has accumulated 150+ commands, but in practice most developers use ~20 regularly. This <strong>free git cheatsheet</strong> is a searchable reference of 60+ commands across 11 categories (setup, basics, branching, merging, rebasing, stashing, history, undoing, remotes, tags, advanced), with a 10-step learning path for newcomers.
</p>
<section id="examples" style="max-width:760px;margin:24px auto 32px">
<h2 style="font-size:18px;margin-bottom:14px">Examples</h2>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Undo the last commit (kept changes)§§git reset --soft HEAD~1§§Removes the commit, keeps your changes staged. Use when you want to amend the commit message or split it.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Stash with a name§§git stash push -m "wip: experimental cache layer"§§Better than bare git stash — your stashes are findable later. Use git stash list to see them.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Revert a pushed commit§§git revert <commit-sha>§§Creates a new commit that undoes the changes — safe on shared branches. Never use git reset --hard on commits that have been pushed.</strong>
</div>
</section>
<aside class="founder-note" style="max-width:760px;margin:24px auto 32px;padding:20px 24px;background:rgba(0,208,132,0.05);border-left:3px solid var(--accent);border-radius:6px;font-size:14px;line-height:1.7;color:var(--text2)"><div style="font-family:var(--mono);font-size:11px;color:var(--accent);letter-spacing:1.5px;text-transform:uppercase;margin-bottom:10px;font-weight:600">💡 Why I built this</div><p style="margin:0 0 12px">I built this because I have worked with git for years and still occasionally forget the difference between reset --soft and reset --mixed when fixing a bad commit. The Atlassian cheatsheet PDF is fine but I want search, learning paths for newcomers, and the actual commands I use weekly. This one has 60+ commands across 11 categories, searchable, with a 10-step learning path for people new to git.</p><p style="margin:0;font-size:13px;color:var(--text3)">— <a href="/about" style="color:var(--accent);text-decoration:none">Anees Ur Rehman</a>, full-stack developer</p></aside>
<section class="article-section">
<h2>Git in production — the workflows, recovery patterns, and modern conventions that ship</h2>
<p>The cheat-sheet above covers the commands. This section covers the patterns: how teams actually use git day to day, the recovery moves that pull you out of any mess, the conventional-commits / semantic-release pipeline that has become standard, and the security practices around signed commits and protected branches that show up in any audited codebase.</p>
<h3>The five commit-message conventions you'll meet</h3>
<table class="ref-table">
<thead><tr><th>Convention</th><th>Example</th><th>Used by</th></tr></thead>
<tbody>
<tr><td>Conventional Commits</td><td><code>feat(auth): add OAuth login</code></td><td>Most modern repos. Drives semantic-release and changelog generation.</td></tr>
<tr><td>Angular style</td><td><code>fix(http): handle 504 retries</code></td><td>Older Angular projects; ancestor of Conventional Commits.</td></tr>
<tr><td>Gitmoji</td><td><code>:sparkles: Add OAuth login</code></td><td>Smaller repos that want visual scanability in <code>git log</code>.</td></tr>
<tr><td>Linear / Imperative</td><td><code>Add OAuth login (LIN-1234)</code></td><td>Linear- and Jira-driven teams. Ticket ID upfront.</td></tr>
<tr><td>"Fix typo"-style</td><td><code>Fix typo</code></td><td>Avoid. Useless in <code>git log</code> 6 months later.</td></tr>
</tbody>
</table>
<p>The 2026 default for serious projects is <strong>Conventional Commits</strong>, because it pairs with <code>semantic-release</code>, <code>release-please</code>, or <code>changesets</code> to auto-generate changelogs and version bumps. The format:</p>
<pre><code>type(scope): summary in present tense
Optional body explaining why, not what.
Wraps at ~72 chars per line.
Optional footer:
BREAKING CHANGE: removed deprecated `oldFunction`.
Refs: LIN-1234, #567</code></pre>
<p>Types: <code>feat</code> (new feature → minor version bump), <code>fix</code> (bug fix → patch), <code>docs</code>, <code>refactor</code>, <code>test</code>, <code>chore</code>, <code>perf</code>, <code>ci</code>, <code>build</code>, <code>style</code>. <code>BREAKING CHANGE</code> in the footer triggers a major bump.</p>
<h3>The recovery patterns that pull you out of any git mess</h3>
<table class="ref-table">
<thead><tr><th>Situation</th><th>Recovery command</th></tr></thead>
<tbody>
<tr><td>Accidentally <code>reset --hard</code> and lost work</td><td><code>git reflog</code> → find the SHA → <code>git reset --hard <sha></code></td></tr>
<tr><td>Committed to wrong branch</td><td><code>git reset --soft HEAD~1</code> → switch branch → <code>git commit</code></td></tr>
<tr><td>Want to undo a pushed commit safely</td><td><code>git revert <sha></code> → push the inverse commit</td></tr>
<tr><td>Want to remove last N commits locally</td><td><code>git reset --hard HEAD~N</code> (private branches only)</td></tr>
<tr><td>Want to combine last N commits into one</td><td><code>git reset --soft HEAD~N</code> → <code>git commit</code></td></tr>
<tr><td>Need to find when a bug was introduced</td><td><code>git bisect start</code> → <code>git bisect bad</code> → <code>git bisect good <old-sha></code></td></tr>
<tr><td>Accidentally committed a secret</td><td><code>git filter-repo</code> (preferred over BFG since 2021); rotate the secret immediately</td></tr>
<tr><td>Want to restore a single file from another commit</td><td><code>git checkout <sha> -- path/to/file</code></td></tr>
<tr><td>Pull is failing because local has divergent history</td><td><code>git pull --rebase</code> or <code>git fetch && git rebase origin/main</code></td></tr>
<tr><td>Detached HEAD with valuable work</td><td><code>git switch -c new-branch</code> while in detached state</td></tr>
</tbody>
</table>
<h3>Modern command verbs — switch and restore</h3>
<p>Since git 2.23 (2019), there are two new commands that disambiguate <code>checkout</code>'s historic dual personality:</p>
<ul>
<li><strong><code>git switch</code></strong> — change branches. Replaces <code>git checkout <branch></code>.</li>
<li><strong><code>git restore</code></strong> — restore files. Replaces <code>git checkout -- file</code> (working tree) and <code>git reset HEAD file</code> (staging).</li>
</ul>
<p><code>git checkout</code> still works for backward compatibility. New scripts and tutorials should use <code>switch</code>/<code>restore</code> — they're clearer to readers.</p>
<h3>Branch protection — the rules every shipping repo enforces</h3>
<p>Production-ready GitHub/GitLab repos set up branch protection on <code>main</code> to prevent the easy mistakes:</p>
<ul>
<li><strong>Require pull requests.</strong> No direct pushes to main.</li>
<li><strong>Require approving reviews.</strong> One or two reviewers depending on team size.</li>
<li><strong>Require status checks to pass.</strong> Tests, lint, security scans, build.</li>
<li><strong>Require conversation resolution.</strong> No merging while review threads are open.</li>
<li><strong>Require signed commits.</strong> Verified signatures only.</li>
<li><strong>Disable force pushes.</strong> Even admins can't rewrite history.</li>
<li><strong>Disable branch deletion.</strong> Belt-and-suspenders against catastrophe.</li>
<li><strong>Linear history.</strong> No merge commits — only fast-forward or squash merges.</li>
</ul>
<h3>Signed commits — the security upgrade most teams skip</h3>
<p>By default, anyone can author a commit with any name and email. The <code>git config user.email</code> setting is purely cosmetic. Signed commits cryptographically prove the commit was made by someone holding the private key.</p>
<p>Two signing methods:</p>
<ul>
<li><strong>GPG signing</strong> (the original): generate a GPG key, register the public key with GitHub/GitLab, run <code>git config commit.gpgsign true</code>. Verified signatures appear with a green badge in the UI.</li>
<li><strong>SSH signing</strong> (since git 2.34, 2021): reuse your existing SSH key. Faster setup, no separate keyring. <code>git config gpg.format ssh</code> and <code>git config user.signingKey ~/.ssh/id_ed25519.pub</code>.</li>
</ul>
<p>Required for SOC 2 audits and increasingly common in financial-services and healthcare codebases.</p>
<h3>The .gitignore patterns every project should ship with</h3>
<pre><code># Editor / OS
.DS_Store
Thumbs.db
.idea/
.vscode/
*.swp
*~
# Dependencies
node_modules/
__pycache__/
*.pyc
vendor/
target/
# Build output
dist/
build/
*.log
# Secrets — NEVER commit these
.env
.env.local
.env.*.local
*.pem
*.key
secrets.json
# Coverage
coverage/
.nyc_output/
# OS-level
.bash_history
.zsh_history</code></pre>
<p>Even with <code>.gitignore</code>, secrets occasionally slip through. Tools like <code>git-secrets</code>, <code>truffleHog</code>, <code>gitleaks</code>, and GitHub's native secret scanning catch them in CI.</p>
<h3>Git hooks — the automation layer most teams under-use</h3>
<p>Git triggers scripts at well-defined moments. The most useful hooks:</p>
<table class="ref-table">
<thead><tr><th>Hook</th><th>Fires</th><th>Common use</th></tr></thead>
<tbody>
<tr><td><code>pre-commit</code></td><td>Before <code>git commit</code> creates the commit</td><td>Run lint, format, simple tests</td></tr>
<tr><td><code>commit-msg</code></td><td>After commit message is entered</td><td>Validate Conventional Commits format</td></tr>
<tr><td><code>pre-push</code></td><td>Before <code>git push</code> sends commits</td><td>Run unit tests, prevent push to main</td></tr>
<tr><td><code>post-merge</code></td><td>After successful merge / pull</td><td>Auto-install new dependencies</td></tr>
</tbody>
</table>
<p>Manage them with <code>husky</code> + <code>lint-staged</code> (Node ecosystem), <code>pre-commit</code> (Python ecosystem), or <code>lefthook</code> (cross-language). Native git hooks live in <code>.git/hooks/</code> but aren't shared across the team — always use a hook manager.</p>
<h3>Monorepo patterns — when "git as a database" hits scale limits</h3>
<p>Once a repo grows past ~10 GB or has thousands of contributors, raw git starts to slow down. The fixes:</p>
<ul>
<li><strong>Shallow clones</strong> (<code>git clone --depth 1</code>) — pull only the latest commit. Useful in CI.</li>
<li><strong>Partial clones</strong> (<code>git clone --filter=blob:none</code>) — defer downloading file contents until needed.</li>
<li><strong>Sparse checkout</strong> (<code>git sparse-checkout init --cone</code>) — work on a subset of the directory tree.</li>
<li><strong>Git LFS</strong> — for large binary assets (videos, ML model weights, design files). Replaces the file with a tiny pointer in the repo.</li>
<li><strong>Microsoft's GVFS / Scalar</strong> — used internally on the Windows codebase (300 GB, 4 million files). Streams contents on demand.</li>
<li><strong>Mercurial / Sapling</strong> — Meta's git replacement, faster on multi-million-file repos.</li>
</ul>
<h3>Common git mistakes that bite</h3>
<ul>
<li><strong>Committing <code>.env</code> with real secrets.</strong> Even after deletion, the secret is in history. Rotate it; use <code>git filter-repo</code> or BFG if you must scrub history.</li>
<li><strong>Force-pushing to a shared branch.</strong> Coordinate first; use <code>--force-with-lease</code>; never force-push to main.</li>
<li><strong>Rebasing already-pushed work.</strong> Causes painful merge conflicts for everyone who pulled the old commits.</li>
<li><strong>Using <code>git pull</code> with merge instead of rebase.</strong> Produces noisy "Merge branch 'main' of …" commits. Set <code>git config pull.rebase true</code> globally.</li>
<li><strong>Committing huge binary files.</strong> Video files, design assets, ML weights — all bloat the clone forever. Use Git LFS or store them out-of-tree.</li>
<li><strong>Long-lived feature branches.</strong> A branch alive for 3 weeks accumulates conflicts. Merge often, ship behind feature flags.</li>
<li><strong>Squash-merging without preserving the original SHAs in the PR description.</strong> Useful for cherry-picking later.</li>
<li><strong>Skipping <code>git fetch</code> before <code>git rebase</code>.</strong> Rebases on stale base; conflicts on push.</li>
</ul>
<aside class="article-aside">
<strong>Authoritative references:</strong>
<ul>
<li><a href="https://git-scm.com/doc" rel="noopener" target="_blank">git-scm.com — Official Git documentation</a></li>
<li><a href="https://www.conventionalcommits.org/" rel="noopener" target="_blank">Conventional Commits — specification</a></li>
<li><a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches" rel="noopener" target="_blank">GitHub — Branch protection rules</a></li>
<li><a href="https://github.com/newren/git-filter-repo" rel="noopener" target="_blank">git-filter-repo — modern history-rewriting tool</a></li>
<li><a href="https://github.com/git-lfs/git-lfs" rel="noopener" target="_blank">Git LFS — large file storage extension</a></li>
<li><a href="https://trunkbaseddevelopment.com/" rel="noopener" target="_blank">trunkbaseddevelopment.com — modern branching reference</a></li>
</ul>
</aside>
</section>
<section class="faq-section">
<h2>Best git cheatsheet for 2026 — what to compare</h2>
<p>Search results for "git cheatsheet", "git commands list", and "git commands pdf" return many static cheat-sheets but most are outdated (no <code>git switch</code> or <code>git restore</code> from 2.23+), incomplete (missing rebase --autosquash, sparse-checkout, worktree), or don't surface the modern recovery patterns (reflog, fsck) that pull you out of real git messes. Here's how the most-used git references compare in 2026:</p>
<table class="ref-table">
<thead><tr><th>Resource</th><th>Modern verbs (switch/restore)</th><th>Recovery patterns</th><th>Searchable</th><th>Cost</th></tr></thead>
<tbody>
<tr><td>FreeDevTool Git Cheatsheet</td><td>Yes</td><td>reflog + fsck + cherry-pick recovery</td><td>Live filter</td><td>Free</td></tr>
<tr><td>GitHub git cheatsheet PDF</td><td>Limited</td><td>Basics only</td><td>No (PDF)</td><td>Free</td></tr>
<tr><td>Atlassian git cheatsheet</td><td>Yes</td><td>Limited</td><td>No</td><td>Free</td></tr>
<tr><td>git-scm.com Pro Git book</td><td>Yes</td><td>Full</td><td>No (browse)</td><td>Free, OSS</td></tr>
<tr><td>Oh My Git! (game)</td><td>Yes</td><td>Interactive</td><td>N/A</td><td>Free</td></tr>
</tbody>
</table>
<h3>What's the difference between git reset, git revert, and git restore in 2026?</h3>
<table class="ref-table">
<thead><tr><th>Command</th><th>Affects</th><th>Safe on shared branch?</th><th>Use case</th></tr></thead>
<tbody>
<tr><td><code>git reset --hard HEAD~1</code></td><td>Branch pointer + working tree + staging</td><td>❌ NEVER</td><td>Throw away local commits before push</td></tr>
<tr><td><code>git reset --soft HEAD~1</code></td><td>Branch pointer only</td><td>❌ NEVER</td><td>Keep changes staged, redo last commit</td></tr>
<tr><td><code>git reset --mixed HEAD~1</code></td><td>Branch pointer + staging</td><td>❌ NEVER</td><td>Default reset; unstage but keep changes</td></tr>
<tr><td><code>git revert HEAD</code></td><td>Creates new inverse commit</td><td>✅ YES</td><td>Undo a pushed commit on shared branch</td></tr>
<tr><td><code>git restore --staged file</code></td><td>Unstages a file (modern syntax)</td><td>✅ YES</td><td>Replace <code>git reset HEAD file</code></td></tr>
<tr><td><code>git restore file</code></td><td>Discards working tree changes</td><td>✅ YES</td><td>Replace <code>git checkout -- file</code></td></tr>
<tr><td><code>git switch branch</code></td><td>Move HEAD to branch</td><td>✅ YES</td><td>Replace <code>git checkout branch</code></td></tr>
</tbody>
</table>
<p>Decision rule: locally only → reset is fine. Pushed already → always revert. Modern syntax (since git 2.23, late 2019) prefers <code>switch</code> + <code>restore</code> over the overloaded <code>checkout</code>. Update muscle memory.</p>
<h3>How do I recover a deleted git branch or lost commit?</h3>
<p>Three recovery commands cover 95% of git accidents. <strong>One</strong>: <code>git reflog</code> shows every change to HEAD over the last 90 days, including deleted branches and reset commits. Find your lost commit's SHA, then <code>git checkout -b recovered-branch <SHA></code>. <strong>Two</strong>: <code>git fsck --lost-found</code> walks the object database and surfaces dangling commits not reachable from any branch — useful when a commit was made then the branch was deleted before push. <strong>Three</strong>: <code>git cherry-pick <SHA></code> applies a single commit from anywhere (including reflog SHAs) onto your current branch. As long as you haven't run <code>git gc --prune=now</code>, lost commits stay in the object database for ~14 days minimum (default <code>gc.pruneExpire</code>).</p>
<h3>Git cheatsheet alternative to GitHub PDF — 4 reasons developers switched</h3>
<ol>
<li><strong>Modern command verbs.</strong> Includes <code>git switch</code> and <code>git restore</code> (introduced 2019); most static PDFs still teach the overloaded <code>git checkout</code> for both branch-switching and file-restoring.</li>
<li><strong>Live search across 60+ commands.</strong> Type "rebase" or "stash" to filter instantly; PDFs require Ctrl+F across multiple pages.</li>
<li><strong>Recovery patterns surfaced.</strong> reflog, fsck, cherry-pick from SHA — the patterns you actually need when something goes wrong on Friday afternoon.</li>
<li><strong>10-step learning path for new users.</strong> Linear init → add → commit → branch → checkout → merge → push → pull → log → reset progression instead of overwhelming alphabet-soup reference.</li>
</ol>
<p>Pair the git cheatsheet with the <a href="/chmod-calculator">Chmod Calculator</a> for SSH-key permission errors (<code>chmod 600 ~/.ssh/id_rsa</code>), the <a href="/cron-parser">Cron Expression Parser</a> for scheduled git pulls, and the <a href="/devops-tools">DevOps Tools hub</a> for the broader CLI utility toolkit.</p>
<h2>Frequently Asked Questions</h2>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">What is the difference between git reset and git revert?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a"><strong>git reset</strong> rewrites history by moving the current branch pointer backward — the commits it moves past become unreachable (though recoverable via reflog for a while). <strong>git revert</strong> creates a new commit that applies the inverse of a previous commit's changes, leaving history intact. Use <code>revert</code> on shared branches where other people may have pulled the commits you want to undo; reset is only safe on private branches nobody else has seen.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">When should I use git rebase instead of merge?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Use <strong>rebase</strong> when you want a clean linear history on a feature branch before merging it into main — it replays your commits on top of the latest base, avoiding merge commits. Use <strong>merge</strong> when you want to preserve the exact parallel history of branches including the point they joined. The golden rule: <em>never rebase commits that exist outside your local repo and that other people may have based work on</em>. Rebase private work; merge public work.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">How do I undo the last commit in git?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">If you haven't pushed yet: <code>git reset --soft HEAD~1</code> keeps your changes staged, <code>git reset --mixed HEAD~1</code> (the default) keeps them unstaged but in your working tree, and <code>git reset --hard HEAD~1</code> discards them entirely. If you've already pushed, don't reset — use <code>git revert HEAD</code> to create an inverse commit that's safe to push on shared branches. To fix just the commit message, <code>git commit --amend</code> opens your editor to edit the previous commit.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">What does git stash do?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">git stash saves your uncommitted changes (tracked files by default) onto a stack and reverts your working directory back to the state of HEAD. It's perfect when you need to quickly switch branches without committing half-finished work. Restore with <code>git stash pop</code> (applies the top stash and removes it from the stack) or <code>git stash apply</code> (applies without removing). Add untracked files with <code>git stash -u</code>, and name stashes with <code>git stash push -m "message"</code>.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">How do I resolve a merge conflict?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">When git reports a conflict, it inserts markers into the affected files: <code><<<<<<< HEAD</code>, <code>=======</code>, and <code>>>>>>>> branch-name</code> surrounding the conflicting regions. Open each conflicted file, edit it to the desired final state (removing all markers), then <code>git add</code> the file to mark the conflict resolved. When all conflicts are resolved, <code>git commit</code> completes the merge. To bail out, <code>git merge --abort</code> returns to the pre-merge state. For rebases, use <code>git rebase --continue</code> or <code>git rebase --abort</code>.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">What's the safest way to rewrite history on a shared branch?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Don't. Seriously — if other people have pulled the branch, rewriting it forces them to untangle their local state, which is error-prone and frustrating. If you <em>must</em> force-push (for example, to remove leaked secrets), coordinate with your team first, use <code>git push --force-with-lease</code> (safer than <code>--force</code> because it fails if someone else pushed in the meantime), and make sure everyone re-clones or runs <code>git fetch && git reset --hard origin/branch</code> after. For routine history cleanup, squash locally before pushing.</div></div>
</section>
<section class="related-section">
<h2>Related Tools</h2>
<div class="related-grid">
<a class="related-card" href="regex-tester"><div class="related-icon">.*</div><div class="related-card-info"><div class="related-card-name">Regex Tester</div><div class="related-card-desc">Test regular expressions</div></div></a>
<a class="related-card" href="json-formatter"><div class="related-icon">{}</div><div class="related-card-info"><div class="related-card-name">JSON Formatter</div><div class="related-card-desc">Format and validate JSON</div></div></a>
<a class="related-card" href="cron-parser"><div class="related-icon">*</div><div class="related-card-info"><div class="related-card-name">Cron Parser</div><div class="related-card-desc">Decode cron expressions</div></div></a>
</div>
</section>
<section class="all-tools-section" aria-label="Browse all FreeDevTool developer tools">
<h2>Browse all 50 free developer tools</h2>
<p class="atc-sub">All tools run in your browser, no signup required, nothing sent to a server.</p>
<div class="all-tools-grid">
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">b64</div>
<div class="atc-cat-title"><h3>Encoding & Conversion</h3><span class="atc-cat-count">11 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/base64-encoder">Base64 Encoder / Decoder</a></li>
<li><a href="/base64-image">Image to Base64</a></li>
<li><a href="/byte-converter">Byte Converter (KB / MB / GB)</a></li>
<li><a href="/case-converter">Case Converter</a></li>
<li><a href="/hex-to-rgb">Hex to RGB / HSL</a></li>
<li><a href="/html-entity">HTML Entity Encoder</a></li>
<li><a href="/json-to-csv">JSON to CSV Converter</a></li>
<li><a href="/px-to-rem">PX to REM Converter</a></li>
<li><a href="/string-escape">String Escape / Unescape</a></li>
<li><a href="/url-encoder">URL Encoder / Decoder</a></li>
<li><a href="/yaml-to-json">YAML to JSON Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">{ }</div>
<div class="atc-cat-title"><h3>Formatting & Generators</h3><span class="atc-cat-count">13 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/color-name">Color Name from Hex</a></li>
<li><a href="/color-picker">Color Palette Picker</a></li>
<li><a href="/css-box-shadow">CSS Box Shadow</a></li>
<li><a href="/css-gradient">CSS Gradient Generator</a></li>
<li><a href="/json-formatter">JSON Formatter / Validator</a></li>
<li><a href="/lorem-ipsum">Lorem Ipsum Generator</a></li>
<li><a href="/markdown-preview">Markdown Preview</a></li>
<li><a href="/password-generator">Password Generator</a></li>
<li><a href="/qr-generator">QR Code Generator</a></li>
<li><a href="/sql-formatter">SQL Formatter</a></li>
<li><a href="/uuid-generator">UUID Generator</a></li>
<li><a href="/word-to-markdown">Word to Markdown</a></li>
<li><a href="/xml-formatter">XML Formatter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">JS</div>
<div class="atc-cat-title"><h3>Minifiers & DevOps</h3><span class="atc-cat-count">6 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/chmod-calculator">chmod Calculator</a></li>
<li><a href="/cron-parser">Cron Expression Parser</a></li>
<li><a href="/css-minifier">CSS Minifier</a></li>
<li><a href="/html-minifier">HTML Minifier</a></li>
<li><a href="/js-minifier">JavaScript Minifier</a></li>
<li><a href="/http-status">HTTP Status Codes</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">#</div>
<div class="atc-cat-title"><h3>Security & Hashing</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/hash-generator">Hash Generator (MD5, SHA)</a></li>
<li><a href="/jwt-decoder">JWT Decoder</a></li>
<li><a href="/jwt-generator">JWT Generator</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">.*</div>
<div class="atc-cat-title"><h3>Code & Text</h3><span class="atc-cat-count">8 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/ai-token-counter">AI Token Counter</a></li>
<li><a href="/char-counter">Character & Word Counter</a></li>
<li><a href="/git-cheatsheet">Git Commands Cheatsheet</a></li>
<li><a href="/number-base">Number Base Converter</a></li>
<li><a href="/regex-explainer">Regex Explainer</a></li>
<li><a href="/regex-tester">Regex Tester</a></li>
<li><a href="/text-diff">Text Diff Checker</a></li>
<li><a href="/wcag-contrast">WCAG Contrast Checker</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">IP</div>
<div class="atc-cat-title"><h3>Network & APIs</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/dns-lookup">DNS Lookup</a></li>
<li><a href="/http-request-builder">HTTP Request Builder</a></li>
<li><a href="/ip-lookup">IP Address Lookup</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">⏱</div>
<div class="atc-cat-title"><h3>Time & Dates</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/relative-time">Relative Time Calculator</a></li>
<li><a href="/timestamp-diff">Timestamp Diff</a></li>
<li><a href="/unix-timestamp-converter">Unix Timestamp Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">SEO</div>
<div class="atc-cat-title"><h3>SEO & Meta</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/meta-tag-generator">Meta Tag Generator</a></li>
<li><a href="/og-preview">Open Graph Preview</a></li>
<li><a href="/slug-generator">URL Slug Generator</a></li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<div>© 2026 FreeDevTool. Built for developers, by developers.</div>
<div class="footer-links"><a href="/all-tools">All Tools</a><a href="/about">About</a><a href="/privacy">Privacy Policy</a><a href="/terms">Terms of Use</a></div>
</footer>
<script>
const GIT_COMMANDS=[
// Setup & Config
{cat:'Setup & Config',cmd:'git config --global user.name "Your Name"',desc:'Set your name for all commits on this machine.',ex:'git config --global user.name "Ada Lovelace"'},
{cat:'Setup & Config',cmd:'git config --global user.email "you@example.com"',desc:'Set your email for all commits.',ex:''},
{cat:'Setup & Config',cmd:'git config --global init.defaultBranch main',desc:'Use "main" instead of "master" for new repos.',ex:''},
{cat:'Setup & Config',cmd:'git config --global pull.rebase true',desc:'Rebase instead of merge on git pull.',ex:''},
{cat:'Setup & Config',cmd:'git config --global core.editor "code --wait"',desc:'Use VS Code as the default editor for commit messages.',ex:''},
{cat:'Setup & Config',cmd:'git config --list',desc:'Show all configured values (global, system, and local).',ex:''},
{cat:'Setup & Config',cmd:'git config --global alias.co checkout',desc:'Create a shortcut: now `git co` works like `git checkout`.',ex:''},
// Starting a Repo
{cat:'Starting a Repo',cmd:'git init',desc:'Create a new empty repository in the current directory.',ex:'Initialized empty Git repository in /path/.git/'},
{cat:'Starting a Repo',cmd:'git clone <url>',desc:'Copy a remote repository into a new local directory.',ex:'git clone https://github.com/user/repo.git'},
{cat:'Starting a Repo',cmd:'git clone <url> <folder>',desc:'Clone into a specific folder name.',ex:'git clone https://github.com/user/repo.git my-folder'},
{cat:'Starting a Repo',cmd:'git clone --depth 1 <url>',desc:'Shallow clone: only the most recent commit. Much faster for large repos.',ex:''},
// Staging & Committing
{cat:'Staging & Committing',cmd:'git status',desc:'Show what has changed since the last commit.',ex:'On branch main\\nChanges not staged for commit:\\n modified: README.md'},
{cat:'Staging & Committing',cmd:'git add <file>',desc:'Stage a specific file for the next commit.',ex:'git add src/index.js'},
{cat:'Staging & Committing',cmd:'git add .',desc:'Stage all changes in the current directory and below.',ex:''},
{cat:'Staging & Committing',cmd:'git add -p',desc:'Interactively stage individual hunks. Best for crafting clean commits.',ex:''},
{cat:'Staging & Committing',cmd:'git restore --staged <file>',desc:'Unstage a file (keep the changes in your working tree).',ex:''},
{cat:'Staging & Committing',cmd:'git commit -m "message"',desc:'Commit staged changes with a short message.',ex:'git commit -m "Fix null pointer in auth handler"'},
{cat:'Staging & Committing',cmd:'git commit -am "message"',desc:'Stage all tracked-file modifications and commit in one step.',ex:''},
{cat:'Staging & Committing',cmd:'git commit --amend',desc:'Modify the most recent commit (message or contents). Do not do this after pushing.',ex:''},
{cat:'Staging & Committing',cmd:'git diff',desc:'Show unstaged changes.',ex:''},
{cat:'Staging & Committing',cmd:'git diff --staged',desc:'Show staged changes (what will be in the next commit).',ex:''},
{cat:'Staging & Committing',cmd:'git diff <branch1>..<branch2>',desc:'Compare two branches.',ex:''},
// Branching & Merging
{cat:'Branching & Merging',cmd:'git branch',desc:'List all local branches. Current branch marked with *.',ex:'* main\\n feature/login'},
{cat:'Branching & Merging',cmd:'git branch <name>',desc:'Create a new branch from the current HEAD (but do not switch).',ex:'git branch feature/checkout'},
{cat:'Branching & Merging',cmd:'git switch <name>',desc:'Switch to an existing branch (replaces old `checkout <name>`).',ex:'git switch main'},
{cat:'Branching & Merging',cmd:'git switch -c <name>',desc:'Create and switch to a new branch in one command.',ex:'git switch -c feature/payments'},
{cat:'Branching & Merging',cmd:'git branch -d <name>',desc:'Delete a branch (only if merged).',ex:''},
{cat:'Branching & Merging',cmd:'git branch -D <name>',desc:'Force-delete a branch, even if unmerged.',ex:''},
{cat:'Branching & Merging',cmd:'git merge <branch>',desc:'Merge another branch into the current one.',ex:'git merge feature/login'},
{cat:'Branching & Merging',cmd:'git merge --no-ff <branch>',desc:'Force a merge commit even if fast-forward is possible.',ex:''},
{cat:'Branching & Merging',cmd:'git merge --abort',desc:'Cancel an in-progress merge and return to pre-merge state.',ex:''},
{cat:'Branching & Merging',cmd:'git branch -m <new-name>',desc:'Rename the current branch.',ex:'git branch -m feature/v2'},
// Remote Operations
{cat:'Remote Operations',cmd:'git remote -v',desc:'List configured remotes and their URLs.',ex:'origin git@github.com:user/repo.git (fetch)\\norigin git@github.com:user/repo.git (push)'},
{cat:'Remote Operations',cmd:'git remote add <name> <url>',desc:'Add a new remote.',ex:'git remote add upstream https://github.com/org/repo.git'},
{cat:'Remote Operations',cmd:'git remote set-url <name> <url>',desc:'Change the URL of an existing remote.',ex:''},
{cat:'Remote Operations',cmd:'git fetch',desc:'Download changes from remote without merging them.',ex:''},
{cat:'Remote Operations',cmd:'git pull',desc:'Fetch and merge (or rebase) changes from the tracked remote branch.',ex:''},
{cat:'Remote Operations',cmd:'git push',desc:'Upload local commits to the tracked remote branch.',ex:''},
{cat:'Remote Operations',cmd:'git push -u origin <branch>',desc:'Push and set upstream tracking. Only needed once per new branch.',ex:''},
{cat:'Remote Operations',cmd:'git push --force-with-lease',desc:'Safer force push: fails if someone else pushed in the meantime.',ex:''},
{cat:'Remote Operations',cmd:'git push origin --delete <branch>',desc:'Delete a branch on the remote.',ex:''},
// Inspection & History
{cat:'Inspection & History',cmd:'git log',desc:'Show commit history from HEAD backwards.',ex:''},
{cat:'Inspection & History',cmd:'git log --oneline',desc:'Compact one-line-per-commit log.',ex:'a3f12c Fix auth bug\\nb2e901 Add login tests'},
{cat:'Inspection & History',cmd:'git log --oneline --graph --all',desc:'ASCII graph of every branch. Indispensable.',ex:''},
{cat:'Inspection & History',cmd:'git log -p <file>',desc:'Show every change to a specific file with diffs.',ex:''},
{cat:'Inspection & History',cmd:'git log --author="name"',desc:'Filter log to commits by one author.',ex:''},
{cat:'Inspection & History',cmd:'git show <sha>',desc:"Display a commit's message, metadata, and diff.",ex:''},
{cat:'Inspection & History',cmd:'git blame <file>',desc:'Annotate each line of a file with the commit that last modified it.',ex:''},
{cat:'Inspection & History',cmd:'git bisect start',desc:'Start binary search for a buggy commit. Mark good/bad until found.',ex:''},
{cat:'Inspection & History',cmd:'git reflog',desc:'Show every change to HEAD. Your safety net for "lost" commits.',ex:''},
// Undoing Changes
{cat:'Undoing Changes',cmd:'git restore <file>',desc:'Discard working-tree changes to a file (revert to HEAD version).',ex:''},
{cat:'Undoing Changes',cmd:'git reset --soft HEAD~1',desc:'Undo the last commit, keeping changes staged.',ex:''},
{cat:'Undoing Changes',cmd:'git reset --mixed HEAD~1',desc:'Undo the last commit, keeping changes unstaged (default).',ex:''},
{cat:'Undoing Changes',cmd:'git reset --hard HEAD~1',desc:'Undo the last commit AND discard its changes. Destructive.',ex:''},
{cat:'Undoing Changes',cmd:'git revert <sha>',desc:'Create a new commit that undoes the given commit. Safe on shared branches.',ex:''},
{cat:'Undoing Changes',cmd:'git clean -fd',desc:'Remove untracked files and directories. Destructive — review with `-n` first.',ex:''},
// Stashing
{cat:'Stashing',cmd:'git stash',desc:'Save uncommitted tracked changes and revert working tree to HEAD.',ex:''},
{cat:'Stashing',cmd:'git stash -u',desc:'Stash including untracked files.',ex:''},
{cat:'Stashing',cmd:'git stash push -m "message"',desc:'Stash with a descriptive label.',ex:''},
{cat:'Stashing',cmd:'git stash list',desc:'List all stashes on the stack.',ex:'stash@{0}: On main: WIP on checkout form'},
{cat:'Stashing',cmd:'git stash pop',desc:'Apply the most recent stash and remove it from the stack.',ex:''},
{cat:'Stashing',cmd:'git stash apply stash@{2}',desc:'Apply a specific stash without removing it.',ex:''},
{cat:'Stashing',cmd:'git stash drop stash@{0}',desc:'Delete a specific stash entry.',ex:''},
// Rebasing
{cat:'Rebasing',cmd:'git rebase <branch>',desc:"Replay your current branch's commits on top of another branch.",ex:'git rebase main'},
{cat:'Rebasing',cmd:'git rebase -i HEAD~3',desc:'Interactively rebase the last 3 commits — squash, reword, reorder, drop.',ex:''},
{cat:'Rebasing',cmd:'git rebase --continue',desc:'Continue a rebase after resolving conflicts.',ex:''},
{cat:'Rebasing',cmd:'git rebase --abort',desc:'Cancel an in-progress rebase and return to the original state.',ex:''},
{cat:'Rebasing',cmd:'git cherry-pick <sha>',desc:'Apply the diff of one commit onto the current branch.',ex:''},
// Tagging
{cat:'Tagging',cmd:'git tag',desc:'List all tags.',ex:''},
{cat:'Tagging',cmd:'git tag <name>',desc:'Create a lightweight tag at the current commit.',ex:'git tag v1.0.0'},
{cat:'Tagging',cmd:'git tag -a <name> -m "message"',desc:'Create an annotated tag (includes message and metadata).',ex:'git tag -a v1.0.0 -m "First stable release"'},
{cat:'Tagging',cmd:'git push origin <tag>',desc:'Push a single tag to the remote.',ex:''},
{cat:'Tagging',cmd:'git push --tags',desc:'Push all local tags.',ex:''},
{cat:'Tagging',cmd:'git tag -d <name>',desc:'Delete a local tag.',ex:''},
// Submodules
{cat:'Submodules',cmd:'git submodule add <url> <path>',desc:'Add a repository as a submodule at the given path.',ex:'git submodule add https://github.com/org/lib.git vendor/lib'},
{cat:'Submodules',cmd:'git submodule update --init --recursive',desc:'Initialize and clone submodules after cloning a parent repo.',ex:''},
{cat:'Submodules',cmd:'git submodule foreach git pull',desc:'Run a command in every submodule.',ex:''},
{cat:'Submodules',cmd:'git submodule deinit <path>',desc:'Unregister a submodule (before removing).',ex:''}
];
function render(q=''){
q=q.toLowerCase();
const filtered=GIT_COMMANDS.filter(c=>
!q||c.cmd.toLowerCase().includes(q)||c.desc.toLowerCase().includes(q)||c.cat.toLowerCase().includes(q)||(c.ex&&c.ex.toLowerCase().includes(q))
);
const empty=document.getElementById('gc-empty');
const list=document.getElementById('gc-list');
if(filtered.length===0){list.innerHTML='';empty.style.display='block';return;}
empty.style.display='none';
const cats={};
filtered.forEach(c=>{(cats[c.cat]=cats[c.cat]||[]).push(c);});
list.innerHTML=Object.entries(cats).map(([cat,cmds])=>
`<div class="gc-cat"><h3>${cat}</h3>${cmds.map((c,i)=>
`<div class="gc-cmd"><div class="gc-cmd-head"><div class="gc-cmd-code">${escape(c.cmd)}</div><button class="gc-cmd-copy" onclick="copyCmd(this,${GIT_COMMANDS.indexOf(c)})">Copy</button></div><div class="gc-cmd-desc">${c.desc}</div>${c.ex?`<div class="gc-cmd-example">${escape(c.ex.replace(/\\n/g,'\n'))}</div>`:''}</div>`
).join('')}</div>`
).join('');
}
function escape(s){return (s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');}
function copyCmd(btn,i){
navigator.clipboard.writeText(GIT_COMMANDS[i].cmd);
const t=document.getElementById('toast');t.style.opacity='1';setTimeout(()=>t.style.opacity='0',1500);
}
document.getElementById('gc-search').addEventListener('input',e=>render(e.target.value));
render();
function toggleFaq(el){el.parentElement.classList.toggle('open');}
</script>
</body>
</html>