> I’ve always understood that git tags are used to mark important points in 
> history

Correct (mark=label)

> putting a tag on a commit, I was getting a snapshot of the whole graph

No, there's no need to perform a snapshot of the whole graph.

Commit id (the 40-bit SHA of a commit) is computed from various properties 
including the content of the commit and the parents, therefore if a single bit 
would have changed in the content, then the ID would be different.

Thus you don't need to perform a whole snapshot (that would be git clone 
--depth=1), because knowing just the ID is enough to identify the version, 
content, and ancestry.

Without anything else, you would work only with the SHA numbers... checking out 
XXXXXX, merging XXXX to YYYY, etc.
As this is very annoying, you have several concepts to help you

* lightweight tag --- this is literally just a text file in 
.git/refs/tags/tag-name that has the ID of the pointed-to commit
* annotated tag --- stored again in `.git/refs/tags/tag-name`, but instead it 
points to an intermediate file that contains info about the person creating the 
tag, the tag message, etc, but not the tag content; instead the intermediate 
file again points to a commit ID (you can look at the content of the 
intermediate file in .git/objects (git cat-file to read it)
* branch is a kind of a "moving tag"; in e.g. `.git/refs/heads/master` you 
would see the ID of the latest commit (just like a lightweight tag)

So branch is in reality just the tip of the branch (the head of it), and the 
previous commits do not really belong to any branch. (You can see this when you 
merge a branch and then delete the merged branch... the commits are still 
there, only the label was removed.). So it would be as if you deleted a tag and 
created it again after each commit.

> So I’ve always understood that by putting a tag on a commit, I was getting a 
> snapshot of the whole graph at that point in time? Thus - by specifying the 
> “:tag name” on the baseline url, you were getting that version?

tags and branches are just labels; you could directly use :<commit sha> in the 
baseline with the same effect
 
> Thinking a bit more, I guess if you want to to actually make some changes 
> from that tag point - you do need to create a -b branch from it (otherwise 
> you have a detached head right?) - is this what you are getting at?

you don't need a branch, you can just carry on from the "detached" head

> Or is there a more obvious thing I am missing that lets you point to a 
> particular version in GIT?

Yes, you can just say, I want code as it was in version <COMMIT-SHA>.


To summarize:
* the commit graph representation has no notion of branches or tags
* you can use commit sha instead of tags/branchs
* tags are just references to particular commits
* branches are just like tags, only the reference changes after each commit
* the data representation is very simple and straight-forward, and you can 
easily view it by hand (from terminal with git cat-file) in the .git folder

Peter

(am I making it more clear or more obscure? :-D)

Reply via email to