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

Confused about `git gc`

From
Yakup Akbay <yakbay@ubicom.com>
Date
Jun 9, 2009, 08:28 UTC
Message-ID
<4A2E1D37.9010909@ubicom.com>

Looks like I didn't quite understand the actual role of `git gc`. I just thought that `git gc` would remove all unreferenced objects during the unpack-pack process. However, I'm not seeing the result what I was expecting from `git gc`.

I'm adding an object into the database, which is ignored by git. Then I expect the object to be removed after `git gc`. But, it's still there.

Please follow:

$ echo "/ignored_file" > .gitignore $ echo "This file is ignored by git. I'm sure that this content has never been existed in the repository before." > ignored_file $ git hash-object -w ignored_file 39cd40a92c0a92bbcbd74ec6879b4936212beebd $ ls .git/objects/ 07 39 9f b9 d0 fa info pack $ ls .git/objects/39/ cd40a92c0a92bbcbd74ec6879b4936212beebd $ git gc Counting objects: 319, done. Delta compression using up to 2 threads. Compressing objects: 100% (147/147), done. Writing objects: 100% (319/319), done. Total 319 (delta 124), reused 319 (delta 124) $ ls .git/objects/39/ cd40a92c0a92bbcbd74ec6879b4936212beebd

As you see, 39cd40a92c0a92bbcbd74ec6879b4936212beebd is still there. Shouldn't it be removed by `git gc`?

What am I overlooking?

Regards, Yakup

Next: Jakub Narebski
Message 1 of 3 in “Confused about `git gc`”
  1. Yakup AkbayJun 9, 2009
  2. Jakub NarebskiJun 9, 2009
  3. Yakup AkbayJun 9, 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.