Subject: Re: Archiving tags/branches?

From: SZEDER Gábor <[email-masked]>
Date: Sat, 18 Oct 2008 12:23:45 +0200

Hi Pete,

On Fri, Oct 17, 2008 at 06:43:46PM -0700, Pete Harlan wrote:
>  If I wanted to archive those, it looks like this would work:
> 
> mkdir .git/refs/archived-tags
> cp -a .git/refs/tags/* .git/refs/archived-tags
> git tag -d <tag-to-hide> # repeat as necessary
> 
> I can then maintain a short list of tags that currently interest me, but
> am guaranteed not to lose old branches (say) referenced by those tags.
> 
> Is there a reason this won't work?

Yes:

$ git --version
git version 1.6.0.2.574.g7d0e0
$ git init
Initialized empty Git repository in /home/szeder/tmp/git/archive/.git/
$ echo 1 >foo
$ git add foo
$ git commit -m bar
Created initial commit 0c92489: bar
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git tag t
$ git update-ref refs/archived-tags/t t
$ git tag -d t
Deleted tag 't'
$ cat .git/refs/archived-tags/t
0c92489da6ec6dfd9875eb590d820fcceb01829b
$ git gc
Counting objects: 3, done.
Writing objects: 100% (3/3), done.
Total 3 (delta 0), reused 0 (delta 0)
$ cat .git/refs/archived-tags/t
cat: .git/refs/archived-tags/t: No such file or directory

So, if you put any tags or branches under refs/whatever-non-standard/,
then it gets deleted when you gc (or when gc is run automatically).

I don't know whether this behaviour is intentional or not, but I have
experienced this the hard way recently.

Regards,
Gábor