If I have 4 branches within the same repo in git and I create a tag, does that tag exist for all branches or just on the single branch? Within GitHub, it says that there is a 1.0.0 tag on every branch, and I am unable to create another 1.0.0 tag on any of the other branchs on the command line because it "already exists". Does a tag preserve the state of all branches at once?
1 Answer
In git, a lightweight tag is simply a unique name which points to a specific commit.
git also has the concept of tag objects, which allow you to also enter a message, and potentially sign it with GPG. However, at the end of the day, these are still just pointing to a specific commit.
A lightweight tag is nearly identical to a branch, except it is not designed to be changed, whereas branches advance and change frequently.
A lightweight tag is simply a file in the .git/refs/tags/ directory. It's contents are a single commit ID.
[jason@step MyProject]$ cat .git/refs/tags/Version-4.9.2
77035b7a66427662f1096444eeb319ba9ab1080b
7 Comments
Andrew Rhyne
So does a tag serve as a snapshot of the entire repo, or a particular branch?
gahooa
In git, every commit is a snapshot of the entire repo. Every branch and tag simply point to a commit. So yes, it is a snapshot.
gahooa
Think of git as a "snapshot management system" with the awesome ability to see and manage differences between snapshots. Under the hood, git has
blobs, trees, and commits. A blob holds file contents. A tree is a simple list of specific blobs and other trees. A commit is a note, date, author, and pointer to a specific tree object (which in turn, points to other blob and tree objects). In that way, a commit is a true snapshot of the state of the ENTIRE repo at that point.gahooa
@AndrewRhyne, you have no idea. Git isn't even in the same universe as svn. We use it for everything from tracking our admin files to every project to /etc on all of our servers. Focus on understanding the data model first (blob, tree, commit, tag), and then everything else will make SO MUCH MORE SENSE. Git is so incredible simple, yet it is the most powerful thing I've ever seen. Kind of like the language Python in a lot of respects.
KingCrunch
@AndrewRhyne
git doesn't provide an remote interface on it's own, but rely on existing technology (namely ssh), where it tunnels it's communication through. This said: As long as your server and especially your SSH-Server is secure, git is secure :) There are other interfaces, like for example for http, but thats a huge topic. |