2

I ran git gc to see how git garbage collector works in general.

enter image description here

But as soon as I ran it,my 15 objects that were shown in .git/objects as blobs, commits, and tree, they are gone. 1. How to undo it and restore those git objects? 2. When I'll run ls, it shows me all the files but what is there status? Where are they at present? They are in the working directory, staging or modified area. And why can't I see them?

Please help me and suggest me If I'm missing some use-case. enter image description here

4
  • 2
    The objects get packed in the pack files, which increases performance. Why would you like to undo the command? It seems to have worked as expected. Commented Feb 17, 2020 at 11:00
  • 4
    You can use git unpack-objects to unpack the pack file again: stackoverflow.com/questions/16972031/… Commented Feb 17, 2020 at 11:03
  • can you please guide how performance increases in this case?
    – echobash
    Commented Feb 17, 2020 at 11:20
  • 2
    Packfiles only store the differences between different versions of a file. This reduces the amount of data that needs to be read from disk for most operations. Diffs particularly profit from the delta compression. Commented Feb 17, 2020 at 11:50

1 Answer 1

1
  1. How to undo it and restore those git objects?

I see that this has been answered in the comments, credits to @Sven.

  1. When I'll run ls, it shows me all the files but what is there status? Where are they at present? They are in the working directory, staging or modified area. And why can't I see them?

Well, assuming you are talking about the "linux" ls (i.e. the one which displays all the files), to see the current status of your git repo, run git status which tells you if any file(s) are there in the staging area. This will also tell you which file(s) are not being tracked hence your directory(the things present in your working folder) minus the untracked file(s) gives you your working directory.

Best

Not the answer you're looking for? Browse other questions tagged or ask your own question.