git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
BLBernd Lommerzheim <bernd@lommerzheim.com>
Date
Jan 29, 2009, 19:31 UTC
Message-ID
<83c97f59a5a5e59f908f3fc125d26adb@lunox.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
Next: Johannes Schindelin
Message 1 of 5 in “"git gc" removes ".git/refs/heads/master".”
  1. Bernd LommerzheimJan 29, 2009
  2. Johannes SchindelinJan 29, 2009
  3. Johannes GilgerJan 29, 2009
  4. Peter BaumannJan 29, 2009
  5. Junio C HamanoJan 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.