what is the difference between tag and branch with git? [duplicate]
Possible Duplicate:
What is the difference between a tag and a branch in git?
What I'd like to do is create checkpoints for different versions of my code. So once I make a bunch of commits, I want to say, "Okay, at this point in the code, this is version 0.1 completed". And then I can make a bunch more commits and do it again and say, "Okay, this point is 0.2 completed".
I know how to make a branch and a tag... I just don't understand the difference, and which one will do what I want ;)
Both branches and tags are essentially pointers to commits. The big difference is that the commit a branch points to changes as you add new commits, and a tag is frozen to a particular commit to mark a point in time as having a certain significance. From one of my favorite Git resources, Pro Git:
Like most VCSs, Git has the ability to tag specific points in history as being important. Generally, people use this functionality to mark release points (v1.0, and so on). In this section, you’ll learn how to list the available tags, how to create new tags, and what the different types of tags are.
A branch in Git is simply a lightweight movable pointer to one of these commits.
A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base.
SOURCE: This duplicate question.
What you want is probably a TAG.
Let's say you have - Super Awesome Product v1.0 that is stable and commited in a git repository.
You make bug fixes and changes in the branch that is v1.0 and you tag them with stuff like:
this fixes work item 1341 - bug ...
this version fixes item 234324 - bug ...
final v1.0
The above are all tags that represent the state of the code ( a LABEL ) when the commit was made. So, when you make v1.5 and a bug comes in for v 1.0, you take the tag final v1.0 and test the bug on it.
NOW! You decide to change the underlying Data Access of Super Awesome product. What do you do? You branch v1.0 and make a new branch called Super Awesome Product NEW DAL branch.
Tags are for snapshots of daily to daily commits. Branches are for more grand scale changes.
Tags are a fundamental building block in git; branches aren't. Git performs checks to make sure tags remain constant, never change, once created pointing at a commit. A branch on the other hand is a mere reference or pointer to a commit, and it can be updated to point at a different commit freely.
精彩评论