Subject: Re: immutable tags?

From: Jakub Narebski <[email-masked]>
Date: Mon, 28 Dec 2009 14:22:34 -0800 (PST)

Carlos Santana <[email-masked]> writes:

> I would like to know if there is any difference between branches and
> tags. Is it only conceptual - convention to be followed by a developer
> or some technical difference?  e.g. : Is it possible to create
> immutable tags so that nothing can be checked in to that 'tagged
> directory'?

There is difference.  You can commit only on top of local branches, in
the refs/heads/* namespace (or on top of detached HEAD).

For branches:

  $ git checkout A   # switches current branch, HEAD points to A
  $ git commit       # creates new commit on branch A, A advances (changes)

  * by default fetch gets all branches
  * by default push transfers matching branches
  * default refspec is refs/heads/*:refs/remotes/origin/*

For tags:

  $ git checkout B   # detaches HEAD, HEAD points directly to B^{} commit
                     # you are on 'no branch'
  $ git commit       # advances HEAD, tag B does not change

  * by default fetch autofollows tags (gets tags that point to commits
    you have)
  * you need to push tags explicitely
  * default refspec is refs/tags/*:refs/tags/* (mirror 1:1)

-- 
Jakub Narebski
Poland
ShadeHawk on #git