# "git gc" removes ".git/refs/heads/master".

5 messages from 2009-01-29 to 2009-01-29. Participants: Bernd Lommerzheim, Johannes Schindelin, Johannes Gilger, Peter Baumann, Junio C Hamano.
Thread: https://gitlist.dev/t/17445

## Bernd Lommerzheim, 2009-01-29 19:31

Subject: "git gc" removes ".git/refs/heads/master".
Message-ID: <83c97f59a5a5e59f908f3fc125d26adb@lunox.net>
URL: https://gitlist.dev/e/83c97f59a5a5e59f908f3fc125d26adb%40lunox.net

```
Hi,

maybe I found a bug in git. When I execute "git gc" in my local repository,
git removes the file ".git/refs/heads/master". Is this an intended behavior
(but why?) or is that a bug?

Some commands to reproduce:
~ $ mkdir tmp; cd tmp
~/tmp $ git init
Initialized empty Git repository in /home/myuser/tmp/.git/
~/tmp $ echo "content" > a
~/tmp $ git add .
~/tmp $ git commit -a -m "first commit"
Created initial commit 0b67f33: first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
~/tmp $ cat .git/refs/heads/master
0b67f33fff4152a912fdbe8819480b8fc1f2e990
~/tmp $ git gc
Counting objects: 3, done.
Writing objects: 100% (3/3), done.
Total 3 (delta 0), reused 0 (delta 0)
~/tmp $ cat .git/refs/heads/master
cat: .git/refs/heads/master: No such file or directory
~/tmp $ cat .git/HEAD
ref: refs/heads/master
~/tmp $ 

I tested this with git v1.6.0.6, v1.6.1.1 and the current master
(a34a9dbb..).


Best regards,

Bernd Lommerzheim

```

## Johannes Schindelin, 2009-01-29 19:50

Subject: Re: "git gc" removes ".git/refs/heads/master".
Message-ID: <alpine.DEB.1.00.0901292050050.3586@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0901292050050.3586%40pacific.mpi-cbg.de
In-Reply-To: <83c97f59a5a5e59f908f3fc125d26adb@lunox.net>

```
Hi,

On Thu, 29 Jan 2009, Bernd Lommerzheim wrote:

> maybe I found a bug in git. When I execute "git gc" in my local 
> repository, git removes the file ".git/refs/heads/master". Is this an 
> intended behavior (but why?) or is that a bug?

No, it packs the refs.  You have no business accessing files in .git/ 
directly :-)

Ciao,
Dscho

```

## Johannes Gilger, 2009-01-29 19:51

Subject: Re: "git gc" removes ".git/refs/heads/master".
Message-ID: <glt1bl$mal$1@ger.gmane.org>
URL: https://gitlist.dev/e/glt1bl%24mal%241%40ger.gmane.org
In-Reply-To: <83c97f59a5a5e59f908f3fc125d26adb@lunox.net>

```
On 2009-01-29, Bernd Lommerzheim <bernd@lommerzheim.com> wrote:
> maybe I found a bug in git. When I execute "git gc" in my local repository,
> git removes the file ".git/refs/heads/master". Is this an intended behavior
> (but why?) or is that a bug?

Good question, and I just found that one out myself. The ref has been 
"packed" (git help pack-refs) and can be found in .git/packed-refs. Hope 
that answers your question.

Greetings,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

```

## Peter Baumann, 2009-01-29 19:55

Subject: Re: "git gc" removes ".git/refs/heads/master".
Message-ID: <20090129195526.GA15475@m62s10.vlinux.de>
URL: https://gitlist.dev/e/20090129195526.GA15475%40m62s10.vlinux.de
In-Reply-To: <83c97f59a5a5e59f908f3fc125d26adb@lunox.net>

```
On Thu, Jan 29, 2009 at 08:31:17PM +0100, Bernd Lommerzheim wrote:
> Hi,
> 
> maybe I found a bug in git. When I execute "git gc" in my local repository,
> git removes the file ".git/refs/heads/master". Is this an intended behavior
> (but why?) or is that a bug?
> 

This is intential, as git gc creates .git/packed-refs in which the
contents of your master branch are stored. The packed-refs help speeding
up the listing of your branches if you have many of them (e.g. many old
historical ones).

Regards,
Peter Baumann

```

## Junio C Hamano, 2009-01-29 20:07

Subject: Re: "git gc" removes ".git/refs/heads/master".
Message-ID: <7vy6wtev12.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy6wtev12.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <83c97f59a5a5e59f908f3fc125d26adb@lunox.net>

```
Bernd Lommerzheim <bernd@lommerzheim.com> writes:

> Hi,
>
> maybe I found a bug in git. When I execute "git gc" in my local repository,
> git removes the file ".git/refs/heads/master". Is this an intended behavior
> (but why?) or is that a bug?
>
> Some commands to reproduce:
> ~ $ mkdir tmp; cd tmp
> ~/tmp $ git init
> Initialized empty Git repository in /home/myuser/tmp/.git/
> ~/tmp $ echo "content" > a
> ~/tmp $ git add .
> ~/tmp $ git commit -a -m "first commit"
> Created initial commit 0b67f33: first commit
>  1 files changed, 1 insertions(+), 0 deletions(-)
>  create mode 100644 a
> ~/tmp $ cat .git/refs/heads/master
> 0b67f33fff4152a912fdbe8819480b8fc1f2e990
> ~/tmp $ git gc
> Counting objects: 3, done.
> Writing objects: 100% (3/3), done.
> Total 3 (delta 0), reused 0 (delta 0)
> ~/tmp $ cat .git/refs/heads/master
> cat: .git/refs/heads/master: No such file or directory
> ~/tmp $ cat .git/HEAD
> ref: refs/heads/master
> ~/tmp $ 

$ grep master .git/packed-refs

```
