From be383ef6d5b449c6363ba4bfb2f5f4597d9ea6a0 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Fri, 22 Mar 2024 09:23:16 -0600 Subject: [PATCH] Notes on git tags and refs. --- .../plugins/obsidian-to-anki-plugin/data.json | 7 +- notes/git/objects.md | 101 ++++++++++++++++++ notes/git/{references.md => refs.md} | 46 +++++++- 3 files changed, 149 insertions(+), 5 deletions(-) rename notes/git/{references.md => refs.md} (77%) diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 1401216..1ae23fb 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -231,7 +231,7 @@ "_journal/2024-02/2024-02-27.md": "f75a0d04a875aeee932343dae0c78768", "filesystems/index.md": "cbd2b0290a3ba3b32abec4bd8bfefad5", "filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa", - "git/objects.md": "e9b98576291ca04496c2f0863f526cfa", + "git/objects.md": "43d825371e820802f2402034fad89480", "git/index.md": "83d2d95fc549d9e8436946c7bd058d15", "encoding/integer.md": "d4866b6e236c3a67631d03582996eca2", "_journal/2024-02-29.md": "f610f3caed659c1de3eed5f226cab508", @@ -298,10 +298,11 @@ "x86-64/index.md": "4769ab45ca374c4225c9c4099220be82", "_journal/2024-03-21.md": "a2572d2d5be0ee7c7f066d846e2f3e77", "_journal/2024-03/2024-03-20.md": "0a73ce399d275fe6ee3134a812f3f4f9", - "_journal/2024-03-22.md": "6c14bacf3e8834359f8512b7d7055acc", + "_journal/2024-03-22.md": "8da8cda07d3de74f7130981a05dce254", "_journal/2024-03/2024-03-21.md": "cd465f71800b080afa5c6bdc75bf9cd3", "x86-64/declarations.md": "60f5b240ea5565b33dc3585169fc41b1", - "x86-64/instructions.md": "c4b116179d2bd1f9510437e000f9c63d" + "x86-64/instructions.md": "c4b116179d2bd1f9510437e000f9c63d", + "git/refs.md": "de99450b5a4282ae1a694492f2b7f251" }, "fields_dict": { "Basic": [ diff --git a/notes/git/objects.md b/notes/git/objects.md index 9f552b7..15c1379 100644 --- a/notes/git/objects.md +++ b/notes/git/objects.md @@ -517,6 +517,107 @@ Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Soft END%% +## Tags + +Tags are (possibly indirect) pointers to a git object. They *usually* point to a commit but aren't required to. There are two types of tags: + +* **Lightweight** tags are [[refs|git refs]] that never move. These aren't really git objects in the same way the other objects are. +* **Annotated** tags are real objects that provide metadata about the object being pointed to. + +%%ANKI +Cloze +{1:Lightweight} tags are to git {2:refs} whereas {2:annotated} tags are to git {1:objects}. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +Creation of which of lightweight and/or annotated tags writes a new ref to disk? +Back: Both. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +Creation of which of lightweight and/or annotated tags writes a new object to disk? +Back: Just annotated tags. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What two kinds of git tags are there? +Back: Lightweight and annotated. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What do git tags point to? +Back: Any git object. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What do git tags *usually* point to? +Back: Commits. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What primitive type does a lightweight tag correspond to? +Back: A git ref. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What primitive type does an annotated tag correspond to? +Back: A git object. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +How many pointers does a lightweight tag introduce? +Back: One. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +How many pointers does an annotated tag introduce? +Back: Two. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +Why is the term "tag object" a slight misnomer? +Back: A lightweight tag is just a ref, not an object. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Cloze +Git objects are to {`.git/objects`} whereas git references are to {`.git/refs`}. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + ## References * Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). \ No newline at end of file diff --git a/notes/git/references.md b/notes/git/refs.md similarity index 77% rename from notes/git/references.md rename to notes/git/refs.md index f12d896..65d77b3 100644 --- a/notes/git/references.md +++ b/notes/git/refs.md @@ -1,5 +1,5 @@ --- -title: References +title: Refs TARGET DECK: Obsidian::STEM FILE TAGS: git tags: @@ -8,7 +8,11 @@ tags: ## Overview -A **reference** is essentially a file containing an oid. The name of the file can then be used to reference the oid. A **symbolic reference** is a file containing the name of another reference. +A **reference** (or **ref**) is essentially a file containing an oid. The name of the file can then be used to reference the oid. A **symbolic reference** is a file containing the name of another reference. The primary refs are: + +* heads (i.e. branches) +* remotes (i.e. remote branches) +* [[objects#Tags|tags]] %%ANKI Basic @@ -50,6 +54,13 @@ Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Soft END%% +%%ANKI +Basic +Where on disk are git remote branch refs stored? +Back: `.git/refs/remotes` +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). +END%% + %%ANKI Basic Where on disk are git remote branch refs stored? @@ -192,6 +203,37 @@ Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Soft END%% +%%ANKI +Cloze +Branches are to {`refs/heads`} whereas remote branches are to {`refs/remotes`}. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What is the primary distinction between local branch refs and remotes? +Back: The remotes are considered read-only. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What safeguard does git employ to keep remotes read-only? +Back: It never updates `HEAD` to point to a remote ref. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + +%%ANKI +Basic +What is prevented by git never updating `HEAD` to a remote ref? +Back: One can't update the remote ref with a commit. +Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). + +END%% + ## References * Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014). \ No newline at end of file