@@ -14,7 +14,7 @@ links: {
1414
1515A ** branch** in Git is essentially a moveable pointer to a specific commit.
1616
17- Branches are incredibly lightweight - creating a branch is just creating a file containing a unique hash
17+ Branches are lightweight - a branch is just a file containing a commit hash.
1818
1919> Files you commit on one branch are not visible when you switch to another.
2020
@@ -28,6 +28,8 @@ Branches are incredibly lightweight - creating a branch is just creating a file
2828
2929- ** Easy rollback** - Discard experimental work if it doesn't work out
3030
31+ - ** Version support** - apply fixes to previous versions
32+
3133---
3234
3335## Listing Branches
@@ -76,15 +78,14 @@ git switch -c feature-user-profile
7678# Good branch names
7779feature/user-authentication
7880bugfix/login-timeout
79- hotfix/security-patch
8081docs/api-documentation
8182refactor/database-queries
8283
8384# Poor branch names
8485fix
8586temp
86- john -branch
87- new-feature
87+ my -branch
88+ new-stuff
8889```
8990
9091---
@@ -107,18 +108,42 @@ git switch feature-user-profile
107108
108109## The HEAD meta-branch
109110
110- Git tracks which is current working branch using ` HEAD ` .
111+ Git tracks the current branch in a * special ref * called ` HEAD ` .
111112
112113It is similar to a branch in that it can be used as an argument where-ever a branch is needed.
113114
114- But it is NOT a real branch - it always points to the current branch (or commit)
115+ But it is NOT a true branch - it points to the current branch
115116
116- ```
117- # display the contents of the commit
118- # that is currently checked out
117+ ---
118+
119+ ![ HEAD pointer] ( https://git-scm.com/book/en/v2/images/head-to-master.png )
120+
121+ > Branches point to commits; HEAD points at a branch
122+
123+ ---
124+
125+ All of the following commands
126+ will do the same thing - display the contents of the * commit*
127+ that is pointed to by the * branch* , that is currently ** checked-out**
128+
129+ ``` bash
119130git show HEAD
131+
132+ git show master
133+
134+ git show f30ab
120135```
121136
137+ ---
138+
139+ ## Checkout
140+
141+ The checkout command does 2 main things:
142+ - Changes the branch that ` HEAD ` points to
143+ - Overwrites the contents of the working directory with
144+ the contents of the commit pointed by the new ` HEAD ` branch
145+
146+
122147---
123148
124149In this example ` HEAD ` is pointing to the ` testing ` branch
@@ -128,6 +153,14 @@ which is one commit ahead of `master`:
128153
129154---
130155
156+ <class-work >
157+
158+ ### Replicate the state of the repository from the picture
159+
160+ </class-work >
161+
162+ ---
163+
131164## Renaming Branches
132165
133166``` bash
@@ -234,7 +267,7 @@ git fetch --prune
234267
235268---
236269
237- ## Branch Lifecycle
270+ ## Branch Life-cycle
238271
2392721 . ** Create** branch from up-to-date main
2402732 . ** Work** on feature with regular commits
0 commit comments