Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between tag and branch with git? [duplicate]

Tags:

git

branch

tags

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 ;)

like image 716
egervari Avatar asked Oct 25 '10 18:10

egervari


People also ask

What is difference between git tag and branch?

The difference between tags and branches are that a branch always points to the top of a development line and will change when a new commit is pushed whereas a tag will not change. Thus tags are more useful to "tag" a specific version and the tag will then always stay on that version and usually not be changed.

What happens when you tag a branch?

Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.

How do I compare a branch with a tag?

You can access the "Compare branches/tags" page from the branch or the tag page. Choose the branches or tags that you want to compare. Commits tab shows the differences of commits between the branches or the tags. Files tab shows the differences of files between the branches or the tags.

What is the point of git tags?

Git Tags are specific reference points in the Git history. Git tags are used to capture the specific point in the history that is further used to point to a released version. A tag does not change like a branch. They don't have a further history of commits after being created.


3 Answers

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.
like image 194
Jimmy Avatar answered Sep 23 '22 05:09

Jimmy


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.

like image 37
Roberto Aloi Avatar answered Sep 24 '22 05:09

Roberto Aloi


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.

like image 35
Vladimir Georgiev Avatar answered Sep 27 '22 05:09

Vladimir Georgiev