-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.json
More file actions
1848 lines (1848 loc) · 87 KB
/
Copy pathpayload.json
File metadata and controls
1848 lines (1848 loc) · 87 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
{
"schemaVersion": "1",
"version": "1.0.0",
"graph": {
"slug": "git-github",
"content": [
{
"locale": "zh-CN",
"name": "Git & GitHub",
"description": "Git & GitHub 图谱覆盖 Git 分布式版本控制的核心命令与模型,以及 GitHub 官方协作、Pull Request、Actions 和仓库治理能力。"
},
{
"locale": "en",
"name": "Git & GitHub",
"description": "The Git & GitHub graph covers Git’s distributed version-control model and core commands, plus GitHub’s official collaboration, pull request, Actions, and repository-governance features."
}
]
},
"nodes": [
{
"slug": "git-github",
"parentSlug": null,
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "Git & GitHub",
"summary": "Git 由 Linus Torvalds 于 2005 年创建,是目前使用最广泛的分布式版本控制系统。`GitHub` 在 Git 基础上提供远程托管、Pull Request、Issues 和 Actions 等协作功能,是全球最大的开源代码托管平台。",
"detail": null
},
{
"locale": "en",
"title": "Git & GitHub",
"summary": "Git was created by Linus Torvalds in 2005 and is the world's most widely used distributed `VCS`. `GitHub` adds remote hosting, Pull Requests, Issues, and Actions on top of Git, making it the largest open-source code collaboration platform.",
"detail": null
}
],
"sortOrder": 0
},
{
"slug": "vcs-basics",
"parentSlug": "git-github",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "版本控制基础",
"summary": "版本控制记录文件随时间的变化,使团队能并行工作、追溯历史、回滚错误。Git 的分布式架构意味着每个克隆都是完整仓库,无需持续连接中央服务器。",
"detail": null
},
{
"locale": "en",
"title": "Version Control Basics",
"summary": "Version control tracks file changes over time, enabling teams to work in parallel, trace history, and roll back mistakes. Git's distributed architecture means every clone is a full repository—no continuous connection to a central server required.",
"detail": null
}
],
"sortOrder": 1
},
{
"slug": "what-is-vcs",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "版本控制概念",
"summary": "版本控制系统(`VCS`)分为集中式(如 `SVN`)和分布式(如 Git)两类。集中式依赖单一服务器,断网无法提交;分布式每个节点持有完整历史,支持离线提交,并行开发效率更高。",
"detail": null
},
{
"locale": "en",
"title": "What Is Version Control",
"summary": "`VCS` comes in two flavors: centralized (e.g. `SVN`) relying on a single server, and distributed (e.g. Git) where every node holds the full history. Git's distributed model enables offline commits and parallel development without a single point of failure.",
"detail": null
}
],
"sortOrder": 2
},
{
"slug": "git-overview",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "Git 核心模型",
"summary": "Git 以快照而非差异存储每次提交,用 `SHA-1/SHA-256` 哈希保证完整性。核心数据结构包括 blob(文件内容)、tree(目录)、commit(提交)、tag(标签)。理解快照模型是掌握分支/合并行为的前提。",
"detail": null
},
{
"locale": "en",
"title": "Git Core Model",
"summary": "Git stores each commit as a snapshot (not a diff) and uses `SHA-1/SHA-256` hashes to guarantee integrity. Core objects are blob (file content), tree (directory), commit, and tag. Understanding the snapshot model is key to reasoning about branching and merging.",
"detail": null
}
],
"sortOrder": 3
},
{
"slug": "git-config",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git config",
"summary": "`git config` 管理 Git 配置,分三层:`--system`(所有用户)、`--global`(当前用户 `~/.gitconfig`)、`--local`(仓库级 `.git/config`)。使用前必须设置 `user.name` 和 `user.email`,否则提交作者信息为空。",
"detail": null
},
{
"locale": "en",
"title": "git config",
"summary": "`git config` manages configuration at three scopes: `--system` (all users), `--global` (current user, `~/.gitconfig`), and `--local` (repository-level `.git/config`). Setting `user.name` and `user.email` is required before making commits.",
"detail": null
}
],
"sortOrder": 4
},
{
"slug": "repository",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "仓库(Repository)",
"summary": "仓库是 Git 跟踪的项目根目录,包含 `.git/` 目录(存储所有历史、对象、引用)。裸仓库(`--bare`)无工作区,仅含 `.git/` 内容,适合作为共享远程仓库的服务端存储。",
"detail": null
},
{
"locale": "en",
"title": "Repository",
"summary": "A repository is the project root tracked by Git, containing the `.git/` directory that stores all history, objects, and refs. A bare repository (`--bare`) has no working tree and is used as a server-side shared remote.",
"detail": null
}
],
"sortOrder": 5
},
{
"slug": "commit-concept",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "提交(Commit)",
"summary": "提交是 Git 中最小的历史单元,包含:完整的文件快照、父提交的引用、作者/提交者信息和提交消息。每个提交有唯一的 `SHA` 哈希,构成有向无环图(`DAG`)。提交一旦写入不可修改(只能创建新提交替代)。",
"detail": null
},
{
"locale": "en",
"title": "Commit",
"summary": "A commit is Git's smallest unit of history: a complete file snapshot, a reference to parent `commit(s)`, `author/committer` info, and a message. Every commit has a unique `SHA` hash; together they form a directed acyclic graph (`DAG`). Once written, commits are immutable—amendments create new commits.",
"detail": null
}
],
"sortOrder": 6
},
{
"slug": "working-tree-index",
"parentSlug": "vcs-basics",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "工作区、暂存区与仓库",
"summary": "Git 将文件状态分为三个区域:工作区(实际文件)、暂存区/索引(`git add` 后的快照,用于准备下次提交)、本地仓库(已提交的历史)。理解这三层是正确使用 `add`、`commit`、`reset`、`restore` 的关键。",
"detail": null
},
{
"locale": "en",
"title": "Working Tree, Staging Area & Repository",
"summary": "Git tracks files across three zones: working tree (actual files on disk), staging `area/index` (snapshot prepared by `git add` for the next commit), and local repository (committed history). Understanding these three layers is essential for using `add`, `commit`, `reset`, and `restore` correctly.",
"detail": null
}
],
"sortOrder": 7
},
{
"slug": "snapshot-model",
"parentSlug": "vcs-basics",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "Snapshot Model",
"summary": "Git 以快照而非增量差异存储每次提交——每个 commit 对象都包含完整的目录树快照。这解释了为什么分支只是轻量级的提交引用,也是 `checkout`、`merge`、`rebase` 等操作围绕提交图移动的根本原因。理解快照模型后,许多「Git 把文件弄丢了」的恐惧都会变成可追踪的对象关系。",
"detail": null
},
{
"locale": "en",
"title": "Snapshot Model",
"summary": "Git stores each commit as a complete snapshot of the repository tree rather than a list of file diffs. This explains why branches are cheap, lightweight references to commits and why `checkout`, `merge`, and `rebase` all navigate a commit graph. Understanding the snapshot model turns most 'Git lost my files' fears into traceable object relationships.",
"detail": null
}
],
"sortOrder": 8
},
{
"slug": "local-workflow",
"parentSlug": "git-github",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "本地基础操作",
"summary": "日常 Git 工作流围绕一组核心命令展开:初始化仓库、跟踪文件变化、提交快照、查看状态和历史。这些命令构成每个开发者每天都会用到的基础操作集。",
"detail": null
},
{
"locale": "en",
"title": "Local Workflow",
"summary": "Daily Git work centers on a core set of commands: initializing a repo, tracking changes, committing snapshots, and inspecting status and history. These commands form the everyday foundation every developer uses.",
"detail": null
}
],
"sortOrder": 9
},
{
"slug": "git-init",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git init",
"summary": "`git init` 在当前目录创建 `.git/` 初始化新仓库;`git init <dir>` 在指定目录创建。已有项目第一次纳入版本控制时使用,之后配合 `git remote add origin` 关联远程仓库再 `push`。",
"detail": null
},
{
"locale": "en",
"title": "git init",
"summary": "`git init` creates a new `.git/` directory in the current folder; `git init <dir>` initializes a named directory. Used when bringing an existing project under version control for the first time, then paired with `git remote add origin` before pushing.",
"detail": null
}
],
"sortOrder": 10
},
{
"slug": "git-add",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git add",
"summary": "`git add <file>` 将文件变更写入暂存区,`git add .` 暂存当前目录所有变更,`git add -p` 交互式选择 hunk(适合拆分大变更为小提交)。暂存区让你精确控制每次提交包含哪些内容。",
"detail": null
},
{
"locale": "en",
"title": "git add",
"summary": "`git add <file>` stages file changes; `git add .` stages everything in the current directory; `git add -p` interactively selects hunks—ideal for splitting large changes into focused commits. The staging area gives precise control over what each commit contains.",
"detail": null
}
],
"sortOrder": 11
},
{
"slug": "git-commit",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git commit",
"summary": "`git commit -m \"message\"` 将暂存区快照写入本地仓库。好的提交消息遵循「标题行 ≤ 50 字符 + 空行 + 正文」规范,以动词开头(`Fix`/`Add`/`Refactor`)。`--allow-empty` 可创建空提交,常用于触发 CI。",
"detail": null
},
{
"locale": "en",
"title": "git commit",
"summary": "`git commit -m \"message\"` writes the staged snapshot to the local repository. Good commit messages follow the convention of a ≤50-char subject line + blank line + body, starting with an imperative verb (`Fix`/`Add`/`Refactor`). `--allow-empty` creates an empty commit, often used to trigger CI.",
"detail": null
}
],
"sortOrder": 12
},
{
"slug": "git-status",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git status",
"summary": "`git status` 显示工作区和暂存区的当前状态:未跟踪文件、已修改文件、已暂存文件。`-s` 输出紧凑格式,适合脚本使用。是每次提交前最常运行的诊断命令。",
"detail": null
},
{
"locale": "en",
"title": "git status",
"summary": "`git status` shows the current state of the working tree and staging area: untracked, modified, and staged files. `-s` gives compact output suitable for scripting. It's the most frequently run diagnostic command before committing.",
"detail": null
}
],
"sortOrder": 13
},
{
"slug": "git-log",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git log",
"summary": "`git log` 展示提交历史,常用选项:`--oneline`(单行摘要)、`--graph`(分支图)、`--author`(按作者过滤)、`-n <N>`(限制条数)、`-- <file>`(文件历史)。`git log --oneline --graph --all` 是查看全分支结构的利器。",
"detail": null
},
{
"locale": "en",
"title": "git log",
"summary": "`git log` displays commit history. Key options: `--oneline` (compact), `--graph` (branch topology), `--author` (filter by author), `-n <N>` (limit count), `-- <file>` (file history). `git log --oneline --graph --all` is the go-to command for visualizing all branches.",
"detail": null
}
],
"sortOrder": 14
},
{
"slug": "git-diff",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git diff",
"summary": "`git diff` 对比工作区与暂存区;`git diff --staged` 对比暂存区与最后一次提交;`git diff <branch1>..<branch2>` 对比两个分支。输出为统一 diff 格式,`+` 表示新增,`-` 表示删除。",
"detail": null
},
{
"locale": "en",
"title": "git diff",
"summary": "`git diff` compares the working tree to the staging area; `--staged` compares the staging area to the last commit; `git diff <branch1>..<branch2>` compares two branches. Output is unified diff format: `+` for additions, `-` for removals.",
"detail": null
}
],
"sortOrder": 15
},
{
"slug": "gitignore",
"parentSlug": "local-workflow",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": ".gitignore",
"summary": "`.gitignore` 文件中的模式告诉 Git 哪些文件/目录不跟踪(如 `node_modules/`、`*.log`、`dist/`)。规则:已跟踪的文件不受影响(需先 `git rm --cached` 取消跟踪);`!` 前缀取反排除;全局 `~/.gitignore` 适用于所有仓库。",
"detail": null
},
{
"locale": "en",
"title": ".gitignore",
"summary": "Patterns in `.gitignore` tell Git which `files/directories` to ignore (e.g. `node_modules/`, `*.log`, `dist/`). Already-tracked files are unaffected—use `git rm --cached` first. `!` negates a pattern; a global `~/.gitignore` applies to all repos on the machine.",
"detail": null
}
],
"sortOrder": 16
},
{
"slug": "git-rm-mv",
"parentSlug": "local-workflow",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git rm / git mv",
"summary": "`git rm <file>` 从暂存区和工作区同时删除文件;`git rm --cached <file>` 仅取消跟踪但保留磁盘文件,适合修正误加入跟踪的文件。`git mv` 等价于先 `mv` 再 `git add`——Git 通过内容比对识别重命名,与使用哪条命令无关。",
"detail": null
},
{
"locale": "en",
"title": "git rm / git mv",
"summary": "`git rm <file>` removes a file from both the index and the working tree; `git rm --cached <file>` untracks it while keeping the disk copy—useful for files accidentally committed to tracking. `git mv` is equivalent to `mv` then `git add`: Git detects renames by content similarity, not by the command used.",
"detail": null
}
],
"sortOrder": 17
},
{
"slug": "branching-merging",
"parentSlug": "git-github",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "分支与合并",
"summary": "分支是 Git 最强大的特性,允许并行开发互不干扰。掌握创建/切换分支、合并策略、变基和冲突解决,是高效 Git 工作流的核心。",
"detail": null
},
{
"locale": "en",
"title": "Branching & Merging",
"summary": "Branching is Git's most powerful feature, enabling parallel development without interference. Mastering branch `creation/switching`, merge strategies, rebase, and conflict resolution is central to an efficient Git workflow.",
"detail": null
}
],
"sortOrder": 18
},
{
"slug": "branch-model",
"parentSlug": "branching-merging",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "分支模型与 HEAD",
"summary": "Git 分支只是指向某个提交的可移动指针,极其轻量。`HEAD` 是当前检出状态的指针,通常指向一个分支(attached),切换到具体 commit 时进入「detached `HEAD`」状态。每次提交,当前分支指针随之向前移动。",
"detail": null
},
{
"locale": "en",
"title": "Branch Model & HEAD",
"summary": "A Git branch is simply a movable pointer to a commit—extremely lightweight. `HEAD` points to the current checkout, usually a branch (attached); checking out a specific commit enters \"detached `HEAD`\" state. With each new commit, the current branch pointer advances automatically.",
"detail": null
}
],
"sortOrder": 19
},
{
"slug": "git-branch",
"parentSlug": "branching-merging",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git branch",
"summary": "`git branch` 列出本地分支;`-a` 包含远程分支;`git branch <name>` 创建新分支;`-d` 删除已合并分支,`-D` 强制删除;`-m` 重命名。命名规范推荐 `feature/`、`fix/`、`release/` 等前缀分类管理。",
"detail": null
},
{
"locale": "en",
"title": "git branch",
"summary": "`git branch` lists local branches; `-a` includes remotes; `git branch <name>` creates a branch; `-d` deletes merged branches, `-D` force-deletes; `-m` renames. Common naming conventions use prefixes like `feature/`, `fix/`, `release/` for organization.",
"detail": null
}
],
"sortOrder": 20
},
{
"slug": "git-switch",
"parentSlug": "branching-merging",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git switch / git checkout",
"summary": "`git switch <branch>` 切换分支(Git 2.23+),`-c` 创建并切换。`git checkout` 功能更多(也能检出文件),但容易混淆;新版推荐用 `switch` 切换分支、`restore` 还原文件,语义更清晰。",
"detail": null
},
{
"locale": "en",
"title": "git switch / git checkout",
"summary": "`git switch <branch>` switches branches (Git 2.23+); `-c` creates and switches. `git checkout` is multipurpose but confusing; modern Git recommends `switch` for branches and `restore` for file restoration to keep intentions explicit.",
"detail": null
}
],
"sortOrder": 21
},
{
"slug": "git-merge",
"parentSlug": "branching-merging",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git merge",
"summary": "`git merge <branch>` 将目标分支合并到当前分支。若可快进则默认快进(无合并提交),`--no-ff` 强制创建合并提交保留拓扑历史。三方合并在两个分支都有新提交时触发,可能产生冲突。",
"detail": null
},
{
"locale": "en",
"title": "git merge",
"summary": "`git merge <branch>` integrates a branch into the current one. When possible, Git fast-forwards (no merge commit); `--no-ff` forces a merge commit to preserve topology. A three-way merge occurs when both branches have diverged and may produce conflicts.",
"detail": null
}
],
"sortOrder": 22
},
{
"slug": "merge-conflicts",
"parentSlug": "branching-merging",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "合并冲突",
"summary": "两个分支对同一文件同一区域做了不同修改时产生冲突。冲突标记 `<<<<<<<`/`=======`/`>>>>>>>` 分隔双方内容,需手动编辑解决后 `git add` 再 `git commit` 完成合并。`git mergetool` 可启动图形化合并工具。",
"detail": null
},
{
"locale": "en",
"title": "Merge Conflicts",
"summary": "Conflicts occur when two branches modify the same region of a file differently. Conflict markers `<<<<<<<`/`=======`/`>>>>>>>` delineate each side; resolve by editing, then `git add` and `git commit` to complete the merge. `git mergetool` opens a graphical merge editor.",
"detail": null
}
],
"sortOrder": 23
},
{
"slug": "git-rebase",
"parentSlug": "branching-merging",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git rebase",
"summary": "`git rebase <base>` 将当前分支的提交「重放」到目标基点之上,产生线性历史。与 merge 不同,rebase 会重写提交 `SHA`,因此**已推送的公共分支不应 rebase**(会破坏他人历史)。常用于个人分支整理提交后再合并到主干。",
"detail": null
},
{
"locale": "en",
"title": "git rebase",
"summary": "`git rebase <base>` replays current branch commits on top of a new base, producing linear history. Unlike merge, rebase rewrites commit `SHAs`—**never rebase already-pushed public branches** as it breaks others' history. Ideal for cleaning up a personal branch before merging into main.",
"detail": null
}
],
"sortOrder": 24
},
{
"slug": "interactive-rebase",
"parentSlug": "branching-merging",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "交互式变基",
"summary": "`git rebase -i <base>` 打开编辑器列出提交,可对每条记录选择 `pick`(保留)、`squash`(合并到前一条)、`reword`(改消息)、`edit`(修改内容)、`drop`(删除)。常用于合并 PR 前整理提交历史,使其清晰可读。",
"detail": null
},
{
"locale": "en",
"title": "Interactive Rebase",
"summary": "`git rebase -i <base>` opens an editor listing commits where each can be `pick` (keep), `squash` (combine with previous), `reword` (edit message), `edit` (amend content), or `drop` (delete). The standard tool for cleaning up a branch's history before opening a PR.",
"detail": null
}
],
"sortOrder": 25
},
{
"slug": "git-cherry-pick",
"parentSlug": "branching-merging",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git cherry-pick",
"summary": "`git cherry-pick <sha>` 将指定提交的变更应用到当前分支,生成新提交(`SHA` 不同)。适合从其他分支选取修复提交而不合并整条分支,例如将 `main` 上的 hotfix 选取到 `release` 分支。",
"detail": null
},
{
"locale": "en",
"title": "git cherry-pick",
"summary": "`git cherry-pick <sha>` applies the changes of a specific commit onto the current branch, creating a new commit with a different `SHA`. Ideal for porting a fix from another branch without merging the entire branch—e.g. backporting a hotfix from `main` to a `release` branch.",
"detail": null
}
],
"sortOrder": 26
},
{
"slug": "merge-squash",
"parentSlug": "branching-merging",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "Squash 合并",
"summary": "`git merge --squash <branch>` 将分支的所有变更压缩为暂存区的一次性改动,需手动提交,结果是主干上一个干净的单提交。与 interactive rebase squash 效果类似,但不保留原分支提交历史,常用于功能分支合并主干时。",
"detail": null
},
{
"locale": "en",
"title": "Squash Merge",
"summary": "`git merge --squash <branch>` folds all branch changes into a single staged change that you commit manually, resulting in one clean commit on the main branch. Similar to an interactive rebase squash but discards the branch's commit history—commonly used when merging feature branches.",
"detail": null
}
],
"sortOrder": 27
},
{
"slug": "fast-forward-merge",
"parentSlug": "branching-merging",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "Fast-forward Merge",
"summary": "当目标分支是当前分支的直接祖先时,Git 默认直接移动分支指针(fast-forward),不创建 merge commit,历史保持线性。使用 `git merge --no-ff` 可强制创建 merge commit 以保留集成边界。团队应明确策略:feature 分支合并是否需要保留 merge 节点用于历史追溯。",
"detail": null
},
{
"locale": "en",
"title": "Fast-forward Merge",
"summary": "When the target branch is a direct ancestor of the current branch, Git simply advances the branch pointer (fast-forward) without creating a merge commit, keeping history linear. Use `git merge --no-ff` to force a merge commit and preserve the integration boundary. Teams should define whether feature branch merges need explicit merge nodes for history traceability.",
"detail": null
}
],
"sortOrder": 28
},
{
"slug": "remote-operations",
"parentSlug": "git-github",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "远程操作",
"summary": "远程操作是团队协作的核心:克隆仓库、推送本地提交、拉取他人变更、管理远程引用。理解 `fetch/pull` 的区别和追踪分支机制,可避免常见的推送冲突。",
"detail": null
},
{
"locale": "en",
"title": "Remote Operations",
"summary": "Remote operations are the backbone of team collaboration: cloning repos, pushing local commits, pulling others' changes, and managing remote refs. Understanding the difference between fetch and pull—and how tracking branches work—prevents common push conflicts.",
"detail": null
}
],
"sortOrder": 29
},
{
"slug": "git-remote-cmd",
"parentSlug": "remote-operations",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git remote",
"summary": "`git remote -v` 列出远程仓库及 `URL`;`git remote add <name> <url>` 添加(`origin` 是克隆后的默认名);`remove` 删除;`set-url` 修改 `URL`(常用于 `HTTP`→`SSH` 切换)。一个本地仓库可以有多个远程。",
"detail": null
},
{
"locale": "en",
"title": "git remote",
"summary": "`git remote -v` lists remotes with `URLs`; `add <name> <url>` adds one (`origin` is the default after cloning); `remove` deletes; `set-url` changes the `URL` (common when switching from `HTTPS` to `SSH`). A local repo can have multiple remotes.",
"detail": null
}
],
"sortOrder": 30
},
{
"slug": "git-clone",
"parentSlug": "remote-operations",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git clone",
"summary": "`git clone <url>` 复制完整仓库(含全部历史)到本地,自动设置 `origin` 并检出默认分支。`--depth 1` 浅克隆只取最近一次提交,适合 CI 环境加速;`--branch <name>` 克隆后直接检出指定分支。",
"detail": null
},
{
"locale": "en",
"title": "git clone",
"summary": "`git clone <url>` copies a full repository (all history) locally and automatically sets up `origin` and checks out the default branch. `--depth 1` performs a shallow clone for CI speed; `--branch <name>` checks out a specific branch after cloning.",
"detail": null
}
],
"sortOrder": 31
},
{
"slug": "git-push",
"parentSlug": "remote-operations",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git push",
"summary": "`git push <remote> <branch>` 将本地提交上传到远程分支。首次推送用 `-u`(`--set-upstream`)建立追踪关系,之后直接 `git push` 即可。若远程有本地没有的提交(非快进),需先 `pull/fetch+merge` 再推送。",
"detail": null
},
{
"locale": "en",
"title": "git push",
"summary": "`git push <remote> <branch>` uploads local commits to a remote branch. Use `-u` (`--set-upstream`) on the first push to establish tracking, enabling bare `git push` afterwards. If the remote has commits the local doesn't (non-fast-forward), fetch and merge before pushing.",
"detail": null
}
],
"sortOrder": 32
},
{
"slug": "git-pull",
"parentSlug": "remote-operations",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git pull",
"summary": "`git pull` 等于 `git fetch` + `git merge FETCH_HEAD`,默认以合并方式整合远程变更。`--rebase` 选项改为变基方式,避免产生合并提交,历史更线性。团队可在 `git config pull.rebase true` 全局统一策略。",
"detail": null
},
{
"locale": "en",
"title": "git pull",
"summary": "`git pull` equals `git fetch` + `git merge FETCH_HEAD`, integrating remote changes via merge by default. `--rebase` rebases instead, avoiding merge commits for a linear history. Teams can standardize with `git config pull.rebase true` globally.",
"detail": null
}
],
"sortOrder": 33
},
{
"slug": "git-fetch",
"parentSlug": "remote-operations",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git fetch",
"summary": "`git fetch` 从远程下载最新对象和引用,但不修改本地工作区或分支。适合先查看远程变更(`git log origin/main..HEAD`)再决定是否合并。`--prune` 清理本地已被远程删除的追踪分支。",
"detail": null
},
{
"locale": "en",
"title": "git fetch",
"summary": "`git fetch` downloads new objects and refs from the remote without touching the local working tree or branches. Useful for inspecting remote changes (e.g. `git log origin/main..HEAD`) before deciding to merge. `--prune` removes tracking branches deleted on the remote.",
"detail": null
}
],
"sortOrder": 34
},
{
"slug": "tracking-branches",
"parentSlug": "remote-operations",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "追踪分支",
"summary": "追踪分支(如 `origin/main`)是远程分支在本地的只读镜像,在 `fetch` 后更新。`git branch -vv` 显示每条本地分支追踪的远程分支及领先/落后的提交数,是诊断推送/拉取问题的常用命令。",
"detail": null
},
{
"locale": "en",
"title": "Tracking Branches",
"summary": "Tracking branches (e.g. `origin/main`) are read-only local mirrors of remote branches, updated on `fetch`. `git branch -vv` shows each local branch's upstream and how many commits `ahead/behind` it is—the go-to command for diagnosing `push/pull` issues.",
"detail": null
}
],
"sortOrder": 35
},
{
"slug": "force-push",
"parentSlug": "remote-operations",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "强制推送",
"summary": "`git push --force` 覆盖远程历史,有破坏他人工作的风险。`--force-with-lease` 更安全:仅在远程分支未被他人更新时才强制推送,是 rebase 后更新远程分支的推荐方式。公共主干分支(`main`/`master`)应通过分支保护规则禁止强制推送。",
"detail": null
},
{
"locale": "en",
"title": "Force Push",
"summary": "`git push --force` overwrites remote history and risks destroying others' work. `--force-with-lease` is safer: it only force-pushes if the remote branch hasn't been updated by others—the recommended way to update a remote after rebasing. Branch protection rules should block force-push on shared branches.",
"detail": null
}
],
"sortOrder": 36
},
{
"slug": "upstream-origin",
"parentSlug": "remote-operations",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "origin / upstream",
"summary": "`origin` 是执行 `git clone` 时自动设置的默认远程名,指向被克隆的仓库地址。Fork 工作流中通常再添加 `upstream` 指向原始仓库,用于拉取上游更新。远程名没有任何魔法,`git remote -v` 随时可以查看每个远程实际指向的 URL 和追踪配置。",
"detail": null
},
{
"locale": "en",
"title": "origin / upstream",
"summary": "`origin` is the default remote name set automatically by `git clone`, pointing to the repository you cloned from. Fork workflows typically add a second remote called `upstream` for the original repository to pull updates from it. Remote names carry no magic—run `git remote -v` to inspect every remote's actual URL and tracking configuration at any time.",
"detail": null
}
],
"sortOrder": 37
},
{
"slug": "undo-recovery",
"parentSlug": "git-github",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "撤销与恢复",
"summary": "Git 提供了丰富的撤销工具,覆盖从「取消暂存」到「彻底回滚提交」的各种场景。选择正确的撤销命令取决于变更是否已推送、是否需要保留工作区内容。",
"detail": null
},
{
"locale": "en",
"title": "Undo & Recovery",
"summary": "Git provides rich undo tools ranging from unstaging files to rolling back commits entirely. Choosing the right command depends on whether changes have been pushed and whether you need to preserve working-tree content.",
"detail": null
}
],
"sortOrder": 38
},
{
"slug": "git-reset",
"parentSlug": "undo-recovery",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git reset",
"summary": "`git reset` 移动 `HEAD`(及当前分支指针)到指定提交。三种模式:`--soft`(移动 `HEAD`,保留暂存区+工作区)、`--mixed`(默认,清空暂存区,保留工作区)、`--hard`(清空暂存区和工作区,会丢失未提交变更)。只用于尚未推送的本地历史。",
"detail": null
},
{
"locale": "en",
"title": "git reset",
"summary": "`git reset` moves `HEAD` (and the current branch pointer) to a specified commit. Three modes: `--soft` (move `HEAD` only, keep staging+working tree), `--mixed` (default—clear staging, keep working tree), `--hard` (clear both—**discards uncommitted changes**). Use only on local, unpushed history.",
"detail": null
}
],
"sortOrder": 39
},
{
"slug": "git-revert",
"parentSlug": "undo-recovery",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git revert",
"summary": "`git revert <sha>` 创建一个新提交来撤销指定提交的变更,不修改历史,适合已推送的公共分支。与 `reset` 的核心区别:`revert` 是安全的「添加撤销记录」,`reset` 是「重写历史」。",
"detail": null
},
{
"locale": "en",
"title": "git revert",
"summary": "`git revert <sha>` creates a new commit that undoes the specified commit's changes without rewriting history—safe for already-pushed public branches. The key distinction from `reset`: `revert` *adds* an undo record; `reset` *rewrites* history.",
"detail": null
}
],
"sortOrder": 40
},
{
"slug": "git-restore",
"parentSlug": "undo-recovery",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git restore",
"summary": "`git restore <file>` 将工作区文件恢复到最后一次提交的状态(丢弃未提交的修改);`--staged` 取消暂存(移出暂存区但保留工作区修改)。Git 2.23+ 推荐用 `restore` 替代 `checkout -- <file>`,语义更明确。",
"detail": null
},
{
"locale": "en",
"title": "git restore",
"summary": "`git restore <file>` discards working-tree changes by reverting to the last committed state; `--staged` unstages files (removes from index, keeps working-tree changes). Introduced in Git 2.23+ as a clearer alternative to `checkout -- <file>`.",
"detail": null
}
],
"sortOrder": 41
},
{
"slug": "git-stash",
"parentSlug": "undo-recovery",
"category": "core",
"content": [
{
"locale": "zh-CN",
"title": "git stash",
"summary": "`git stash` 将未完成的工作区和暂存区变更保存到栈中,让工作区回到干净状态(可切换分支处理紧急任务)。`git stash pop` 恢复最近一次储藏并从栈中移除;`list` 查看所有储藏;`-u` 包含未跟踪文件。",
"detail": null
},
{
"locale": "en",
"title": "git stash",
"summary": "`git stash` saves uncommitted working-tree and staged changes onto a stack, cleaning the working tree for branch switching or urgent fixes. `git stash pop` restores the latest stash and removes it from the stack; `list` shows all stashes; `-u` includes untracked files.",
"detail": null
}
],
"sortOrder": 42
},
{
"slug": "git-reflog",
"parentSlug": "undo-recovery",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git reflog",
"summary": "`git reflog` 记录本地 `HEAD` 的所有移动历史(即使 `reset --hard` 或误删分支),默认保留 90 天。当误操作丢失提交时,可通过 reflog 找回 `SHA` 再 `git reset` 或 `git checkout` 恢复,是「最后的救命稻草」。",
"detail": null
},
{
"locale": "en",
"title": "git reflog",
"summary": "`git reflog` records every local `HEAD` movement—even after `reset --hard` or deleted branches—retained for 90 days by default. When commits are accidentally lost, find the `SHA` in the reflog and use `git reset` or `git checkout` to recover them. It's Git's 'last resort' recovery tool.",
"detail": null
}
],
"sortOrder": 43
},
{
"slug": "amend-commit",
"parentSlug": "undo-recovery",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "修改提交(amend)",
"summary": "`git commit --amend` 将当前暂存区的内容合并到最近一次提交,并可修改提交消息。本质上是创建新提交替代旧提交(`SHA` 改变),因此只能用于尚未推送的提交。推送后修改需配合 `--force-with-lease`。",
"detail": null
},
{
"locale": "en",
"title": "Amending Commits",
"summary": "`git commit --amend` merges staged changes into the last commit and lets you edit the message. It creates a replacement commit (changing the `SHA`), so it should only be used on unpushed commits. After pushing, amendment requires `--force-with-lease`.",
"detail": null
}
],
"sortOrder": 44
},
{
"slug": "clean-untracked",
"parentSlug": "undo-recovery",
"category": "rare",
"content": [
{
"locale": "zh-CN",
"title": "git clean",
"summary": "`git clean` 删除工作区中未被 Git 跟踪的文件和目录,常用于清除构建产物或恢复干净工作区。关键参数:`-n` 预览将被删除的内容(强烈建议先执行)、`-f` 确认删除、`-d` 包含未跟踪目录、`-x` 同时删除 `.gitignore` 忽略的文件。这些删除通常无法从 reflog 恢复,操作需谨慎。",
"detail": null
},
{
"locale": "en",
"title": "git clean",
"summary": "`git clean` removes untracked files and directories from the working tree, typically used to clear build artifacts or restore a pristine state. Key flags: `-n` to preview what would be deleted (strongly recommended first), `-f` to confirm execution, `-d` to include untracked directories, `-x` to also remove `.gitignore`-ignored files. These deletions bypass Git history and are generally unrecoverable from reflog.",
"detail": null
}
],
"sortOrder": 45
},
{
"slug": "advanced-git",
"parentSlug": "git-github",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "高级 Git 特性",
"summary": "超出日常工作流的进阶工具:调试、自动化、多仓库管理和历史分析。这些特性在特定场景下能显著提升效率,是区分初级和高级 Git 用户的关键。",
"detail": null
},
{
"locale": "en",
"title": "Advanced Git Features",
"summary": "Advanced tools beyond the everyday workflow: debugging, automation, multi-repo management, and history analysis. These features dramatically improve efficiency in the right scenarios and distinguish intermediate from advanced Git users.",
"detail": null
}
],
"sortOrder": 46
},
{
"slug": "git-tags",
"parentSlug": "advanced-git",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git tag",
"summary": "标签是指向某个提交的固定引用,通常用于标记版本发布(如 `v1.2.0`)。轻量标签只是一个引用;注解标签(`-a`)含独立的标签对象,有作者/日期/消息,是发布的推荐形式。`git push origin --tags` 推送所有标签。",
"detail": null
},
{
"locale": "en",
"title": "git tag",
"summary": "A tag is a fixed ref pointing to a commit, typically used to mark releases (e.g. `v1.2.0`). Lightweight tags are just refs; annotated tags (`-a`) have their own tag object with author, date, and message—the recommended form for releases. Push tags with `git push origin --tags`.",
"detail": null
}
],
"sortOrder": 47
},
{
"slug": "git-bisect",
"parentSlug": "advanced-git",
"category": "common",
"content": [
{
"locale": "zh-CN",
"title": "git bisect",
"summary": "`git bisect` 用二分查找定位引入 bug 的提交。流程:`git bisect start` → 标记坏提交(`bad`)和已知好提交(`good`)→ Git 自动检出中间提交 → 逐步标记 `good/bad` → 自动找出第一个坏提交。`git bisect run <script>` 可完全自动化该过程。",
"detail": null
},
{
"locale": "en",
"title": "git bisect",
"summary": "`git bisect` uses binary search to find the commit that introduced a bug. Workflow: `git bisect start` → mark a `bad` commit and a known-`good` commit → Git checks out the midpoint → mark each as `good/bad` → Git identifies the first bad commit. `git bisect run <script>` fully automates the process.",
"detail": null
}
],
"sortOrder": 48
},
{