Git gc

git, lots of garbage like file revisions and unreachable objects get accumulated in the .git folder. On large repositories and long-term projects, this affects both the operating performance as well as the disk space utilization. Hence, to clean up the garbage, we have the git garbage collector, git gc. To clean up the garbage, we run the git command

git gc
git gc will not affect the remote repository. This will just optimize the local repository. Hence, we can run git gc in any repositories. Users are encouraged to run git gc on a regular basis to keep the repositories clean and the to enhance the performance.   If we want a deeper cleaning, we can run the –aggressive option.
git gc --aggressive
This takes a longer time to run but is more effective than normal garbage collection. This option is not required to run often.   We have an option to check if housekeeping is required or not. We run the –auto option for this. If no housekeeping is required, the command exits without performing any action.
git gc --auto
If we need to prune all objects before a particular date, we can use the following command
git gc --prune=<date>
If we need to prune all objects irrespective of the date, we can use
git gc --prune=all
If we do not need to prune, we can use the following command
git gc --no-prune
We can force for a garbage collection to run even while another git gc is running by forcing it like the given syntax
git gc --force
    git gc is very helpful in keeping our local repositories clean and a better performance of our hard disks.]]>