@@ -4,6 +4,41 @@ title: GitHub Advanced
4
4
description : Mastering Git and GitHub
5
5
---
6
6
7
+ This curriculum will be your companion to the GitHub Advanced class taught by the GitHub Training Team and other educational groups. In this course, you'll explore strategies for branch and history rewriting, temporary storing and recovery techniques, and Git technology mechanics for faster problem solving.
8
+
9
+ ### Understanding Git
10
+
11
+ * Directed acyclic graph
12
+ * Tree object
13
+ * Blob object
14
+ * SHA1
15
+
16
+ {% capture svg_path %}../assets/diagrams/commit-data-structure.svg{% endcapture %}
17
+ {% include svg %}
18
+
19
+ * Linked list of commits
20
+ * First commit has ` nil ` parent
21
+ * Integrity checking with ` git gc `
22
+
23
+ {% capture svg_path %}../assets/diagrams/commit-dag.svg{% endcapture %}
24
+ {% include svg %}
25
+
26
+ #### Treeish & commitish
27
+
28
+ * Simple ways of describing history points
29
+ * Easier-to-describe and understand numerically
30
+ * Application of patterns works on [ GitHub] ( https://help.github.com/articles/comparing-commits-across-time )
31
+
32
+ ```
33
+ HEAD
34
+ HEAD^^
35
+ HEAD~2
36
+ HEAD@{one.day.ago}
37
+ HEAD@{today}
38
+ ```
39
+
40
+
41
+
7
42
### Common branching strategies
8
43
9
44
#### Summary
@@ -107,36 +142,18 @@ $ git checkout -b [branch] [base]
107
142
``` bash
108
143
# Stage by patch
109
144
$ git add -p [file]
110
- ```
111
-
112
-
113
- ### Understanding Git
114
- {% capture svg_path %}../assets/diagrams/commit-data-structure.svg{% endcapture %}
115
- {% include svg %}
116
-
117
- * Directed acyclic graph
118
- * Tree object
119
- * Blob object
120
- * SHA1
121
-
122
- {% capture svg_path %}../assets/diagrams/commit-dag.svg{% endcapture %}
123
- {% include svg %}
124
145
125
- * Linked list of commits
126
- * First commit has ` nil ` parent
127
- * Integrity checking with ` git gc `
146
+ # Unstage by patch
147
+ git reset reset HEAD -p [file]
148
+ `` `
128
149
150
+ ### Branch best practices
129
151
130
- ### Best Practices
131
- * Collapsing commits during merge
152
+ * Pros/cons of collapsing commits during merge
153
+ * Relation to branching strategies and deliverable expectations
132
154
* Checking merge state
133
155
* Cleaning up branches
134
156
135
- #### Squash merging
136
- * Collapsing commits during merge
137
- * Pros/cons (loss of granularity)
138
- * Relation to branching strategies and deliverable expectations
139
-
140
157
``` shell
141
158
$ git merge --squash [branch]
142
159
```
@@ -249,16 +266,13 @@ $ git stash -p
249
266
### Incorporating History
250
267
251
268
* Reusing small pieces of code with ` cherry-pick `
252
- * Why use ` cherry-pick ` instead of ` merge ` ?
253
- * What happens when you ` cherry-pick ` ?
254
- * Maintaining ` author ` and ` committer ` fields
255
- * Tracing any cherry-picks with ` -x ` commit message metadata
256
- * ` -x ` metadata hyperlinked on GitHub
257
- * ` $ git cherry ` to view absent commits
258
- * Rebase interactive
259
- * Can include cherry-pick
260
- * Must remember to continue the rebase
261
- * Alters history
269
+ * Why use ` cherry-pick ` instead of ` merge ` ?
270
+ * What happens when you ` cherry-pick ` ?
271
+ * Maintaining ` author ` and ` committer ` fields
272
+ * Tracing any cherry-picks with ` -x ` commit message metadata
273
+ * ` -x ` metadata hyperlinked on GitHub
274
+ * ` $ git cherry ` to view absent commits
275
+ * Can include cherry-pick during rebase interactive
262
276
263
277
``` shell
264
278
# Generate new commit on current branch
@@ -325,7 +339,7 @@ $ git add [conflicting-file]
325
339
$ git rebase --continue
326
340
```
327
341
328
- ### Reordering History
342
+ #### Reordering History
329
343
330
344
* Reorder commits
331
345
* Rewrite history entirely
@@ -352,7 +366,7 @@ $ git rebase -i --autosquash [ref]
352
366
```
353
367
354
368
355
- ### Fixing Branches
369
+ #### Fixing Branches
356
370
* This mode of rebase change where branch history begins
357
371
* Moving blocks of history around
358
372
@@ -369,7 +383,7 @@ $ git rebase --onto <newbase> <upstream> <HEAD|branch>
369
383
370
384
### Cutting Releases
371
385
372
- ### Summary
386
+ #### Summary
373
387
* Why create a tag through the web UI?
374
388
* Not a branch HEAD. Points to a specific commit.
375
389
* Attaching binaries to releases (Web UI and API)
@@ -407,7 +421,7 @@ $ git push origin :[tag-name-to-delete]
407
421
```
408
422
409
423
410
- ### Reviewing synchronizing
424
+ ### Reviewing & synchronizing
411
425
412
426
#### Reviewing remote branches
413
427
* PRs to horizontal contributors
@@ -455,21 +469,7 @@ $ git checkout FETCH_HEAD
455
469
$ git branch < newbranchname> FETCH_HEAD
456
470
```
457
471
458
-
459
- ### Customizing Interaction
460
- * Specification for retrieval and pushing
461
- * Implied on fetch, pull, and push
462
- * Altered by option switches like ` --tags `
463
- * Stored in ` .git/config `
464
- * Ability to retrieve Pull Request branches
465
-
466
- ``` shell
467
- $ git fetch [repo-url] [source]:[destination]
468
- $ git config --add remote.[upstream].fetch " +refs/pull/*/head:refs/remotes/[upstream]/pull/*"
469
- ```
470
-
471
-
472
- ### Maintaining Remotes
472
+ #### Maintaining, customizing remotes
473
473
* Remove non-matching _ local_ remote branches
474
474
* Remove non-matching remote upstream branches
475
475
* Remove only remote upstream branch
@@ -483,6 +483,17 @@ $ git fetch --prune
483
483
$ git push origin :< branch-name>
484
484
```
485
485
486
+ #### Customizing Interaction
487
+ * Specification for retrieval and pushing
488
+ * Implied on fetch, pull, and push
489
+ * Altered by option switches like ` --tags `
490
+ * Stored in ` .git/config `
491
+ * Ability to retrieve Pull Request branches
492
+
493
+ ``` shell
494
+ $ git fetch [repo-url] [source]:[destination]
495
+ $ git config --add remote.[upstream].fetch " +refs/pull/*/head:refs/remotes/[upstream]/pull/*"
496
+ ```
486
497
487
498
### Aggregating repositories
488
499
507
518
$ git submodule update --init --recursive
508
519
```
509
520
510
-
511
- ### Incorporating dependencies with subtree
521
+ #### Dependencies with subtree
512
522
513
523
* Alternative to submodule
514
524
* All files available advantage
@@ -549,10 +559,22 @@ $ git merge --squash
549
559
* Hub and GH merging into one project
550
560
551
561
``` shell
562
+ # Create a new public repository on your GitHub account
552
563
$ gh create
564
+
565
+ # Create a new private repository on your GitHub account
566
+ $ gh create -p
567
+
568
+ # Open a Pull Request for the current branch
553
569
$ gh pull-request
570
+
571
+ # Create a fork of the cloned repository on your GitHub Account
554
572
$ gh fork
573
+
574
+ # Launch a web browser with the branch comparison view
555
575
$ gh compare
576
+
577
+ # Launch a web browser to the repository home page
556
578
$ gh browse
557
579
```
558
580
@@ -644,20 +666,7 @@ $ git clean -fd
644
666
$ git clean -fx
645
667
```
646
668
647
- ### Treeish & commitish
648
-
649
- #### Summary
650
- * Simple ways of describing history points
651
- * Easier-to-describe and understand numerically
652
-
653
- #### Details
654
- ```
655
- HEAD
656
- HEAD^^
657
- HEAD~2
658
- ```
659
-
660
- ### Diff Tool
669
+ ### Diff & merge tool
661
670
662
671
#### Summary
663
672
* [ P4Merge] ( http://www.perforce.com/downloads/Perforce/20-User )
@@ -688,12 +697,6 @@ A sample `.gitconfig` file:
688
697
prompt = false
689
698
```
690
699
691
- ### Merge Tool
692
-
693
- #### Summary
694
- * Same as difftool, but 3-way comparison
695
-
696
- #### Details
697
700
698
701
Mergetool execution:
699
702
0 commit comments