1

As I understand from this answer, each time I stage a file (or part of), git will create an index of the file as blob for including in the next commit.

The question is: will git keep that content after I unstage that file out of the index (as git suggest: git reset HEAD -- file). May be in the form of some dangling object as long as I'm not doing a garbage collect.

Please correct me if I'm wrong

Community
  • 1
  • 1
KenIchi
  • 1,129
  • 10
  • 22

1 Answers1

1

Yes, you will have a dangling object.

me@myvm:/scratch/index2  (master)$ git hash-object foo
aff2b43e2799984a7b49aaafdeae5c424f7e4121
me@myvm:/scratch/index2  (master)$ git add foo
me@myvm:/scratch/index2  (master)$ git reset foo
me@myvm:/scratch/index2  (master)$ git fsck
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob aff2b43e2799984a7b49aaafdeae5c424f7e4121
me@myvm:/scratch/index2  (master)$ 
Andrew C
  • 13,845
  • 6
  • 50
  • 57
  • Thanks, you've just answer @TimBiegeleisen 's question. BTW, you can recover an accidentally deleted file by a `git fsck` if you've ever index it. Just in case! – KenIchi Apr 14 '15 at 07:26