From: John McKown 
  To: git-users@googlegroups.com 
  Sent: Monday, November 26, 2012 6:07 PM
  Subject: [git-users] deletion of git "object"?


  OK, this is more a question to help me understand git internals than an 
actual problem that I am having. But suppose I create a new branch. "git 
checkout -b newbranch". I am now in the "newbranch" branch. So I create a new 
file in my working directory such as: "date >ldate". I now have ldate in my 
working directory. I do: "git add ldate" and "git commit -m 'added ldate to 
track last date'". The contents of ldate are kept in a git object whose name is 
the sha1sum of the contents. I now decide this is silly. So I want to eliminate 
"newbranch". The simpliest way, not having done a "git push" is to just kill it 
with "git branch master;git branch -D newbranch". Now, after this, is the git 
object for the now non-existent ldate file already cleaned up? Or do I need to 
do something else, such as "git gc", "git prune"? I'm pretty sure that the "git 
gc" is the best bet. 

  -- 
John,

The objects are still there for a while. There is I believe an automatic 
cleanup after, IIRC 30 days, that cleans the logs, reflogs and other loose 
items that are no longer referenced  [1]. There are even 'lost and found' 
methods should the worst happen and you need to find a dropped object. 

I think (but don't quote me) that the branch creation / deletion log is now 
enabled by default so it should be possible to immediately recover the deleted 
branch. 

There is usually no need to do a special 'git gc' (garbage collection), but old 
habits .....

Philip 
[1] it could be that it is the git gc auto that ensures the 30 days .. I just 
let the tools do their thing ;-)

-- 


Reply via email to