Home > Software design >  Is it safe to delete the pack files from .git/objects/?
Is it safe to delete the pack files from .git/objects/?

Time:02-13

I'm now planning to archive/deprecate a repository and move it to an external drive. However, some large pack files in .git/objects/pack could not be transferred because they were larger than 4GB. I'm aware that directly deleting the pack files would rewrite the history, but I'm wondering whether it is fine to just remove the files if I am sure that I'm not going to retrieve any files from the history in the future. Are there any other drawbacks of directly removing the whole pack folder? I assume that other files in the repo won't be influenced, but just their backups. Is this correct?

CodePudding user response:

If you do that, you'll make the whole thing useless as a git repo, in which case you might as well remove all of .git.

If your concern is files over 4GiB (presumably because of FAT filesystems), how about using git repack -ad --max-pack-size=3G, which will rewrite all of the objects into new packs, ensuring that none of the pack files is too large?

CodePudding user response:

but I'm wondering whether it is fine to just remove the files if I am sure that I'm not going to retrieve any files from the history in the future

It is just fine if you are never going to want any of the history again — because it will destroy that history, forever. In fact, if you are never going to want any of the history again, just delete the .git directory and all its contents. The enclosing folder (which you are about to move to an external drive) won't be a "repository" any more, but it will contain the current state of the project.

  • Related