The .git/objects in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage.
I have tried git add -A
, as well as other commands to update the index and remove nonexistent files. I gather, perhaps incorrectly, that the files with two character names in the directory are blobs. I have tried rolling back to previous commits, but no luck.
What can I do to clean this directory?
Deleting the . git folder does not delete the other files in that folder which is part of the git repository. However, the folder will no longer be under versioning control.
The . git folder is hidden to prevent accidental deletion or modification of the folder. The version history of the code base will be lost if this folder is deleted. This means, we will not be able to rollback changes made to the code in future.
No, there isn't. But you can store in git a text files with the 2 or 3 commands you use to reconfigure each repository. You can make it a .
If you added the files and then removed them, the blobs still exist but are dangling. git fsck
will list unreachable blobs, and git prune
will delete them.
If you added the files, committed them, and then rolled back with git reset --hard HEAD^
, they’re stuck a little deeper. git fsck
will not list any dangling commits or blobs, because your branch’s reflog is holding onto them. Here’s one way to ensure that only objects which are in your history proper will remain:
git reflog expire --expire=now --all git repack -ad # Remove dangling objects from packfiles git prune # Remove dangling loose objects
Another way is also to clone the repository, as that will only carry the objects which are reachable. However, if the dangling objects got packed (and if you performed many operations, git may well have packed automatically), then a local clone will carry the entire packfile:
git clone foo bar # bad git clone --no-hardlinks foo bar # also bad
You must specify a protocol to force git to compute a new pack:
git clone file://foo bar # good
Have you tried the git gc
command?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With