22title : ' Advanced git features'
33description : ' Finding specific commits, using multiple working trees and submodules'
44order : 9
5- state : ' upcoming '
5+ state : ' covered '
66tags : ['git']
77links : {
88 ' Referencing commits docs ' : ' https://git-scm.com/docs/gitrevisions' ,
@@ -32,6 +32,7 @@ B~1 # A (parent)
3232
3333* parents* vs * ancestors*
3434![ history with merge] ( https://git-scm.com/book/en/v2/images/basic-merging-2.png )
35+
3536``` bash
3637master^ # C4 -- first parent of a merge commit
3738master^2 # C5 -- second parent of a merge commit
@@ -64,6 +65,7 @@ git log -g master
6465---
6566
6667This adds yet another way to reference commits:
68+
6769``` bash
6870# which commit did master point to 3 moves ago
6971master@{3}
@@ -101,6 +103,7 @@ by default git does **NOT** guarantee that commit author is who they say they ar
101103
102104For projects that require extra security, each commit can be signed.
103105This is possible by using git in conjunction with ` gpg ` and the ` -S ` flag:
106+
104107``` bash
105108# create a signed commit using the configured pgp key
106109git commit -S -m " you can be sure I made this commit"
@@ -127,6 +130,7 @@ Tags can be used to mark important milestones in a project's history (such as re
127130---
128131
129132Git supports 2 types of tags:
133+
130134- ** Lightweight** - very similar to a branch, but cannot be changed
131135
132136- ** Annotated** - similar to a signed commit, but holding additional tagging details
@@ -136,7 +140,7 @@ Git supports 2 types of tags:
136140### Lightweight tags
137141
138142The main difference between a Lightweight tag and a branch is that tags
139- ** CANNOT** be changed to point to a different commit.
143+ ** CANNOT** be changed to point to a different commit.
140144
141145``` bash
142146# tag the current commit as v2
@@ -181,6 +185,7 @@ git tag -d v1.75-tmp
181185---
182186
183187Tags are NOT shared by default, you have to push them explicitly:
188+
184189``` bash
185190# push all tags to the origin remote
186191git push origin --tags
@@ -230,11 +235,12 @@ You can use an appropriate command to automatically validate if the commit is go
230235## Multiple work-trees
231236
232237Git allows you to have multiple versions checked-out at the same time:
238+
233239``` bash
234240# creates a branch called bugfix and checks it out
235241# into a working directory called bugfix
236242# in the parent of the current directory
237- git workspace add ../bugfix
243+ git worktree add ../bugfix
238244
239245# checkout branch origin/broken into a
240246# separate working directory in your home directory
@@ -310,7 +316,6 @@ You can then push each line to its own remote (public and private).
310316
311317---
312318
313-
314319## Submodules
315320
316321If you put a git repository inside another git repository,
@@ -339,4 +344,3 @@ git submodule add path/to/other/repo
339344# clone a repository including all submodules
340345git clone --recurse submodules
341346```
342-
0 commit comments