Git 🌙
Chapters ▾ 2nd Edition

A3.11 Appendix C: Git команди - Administration

Administration

If you’re administering a Git repository or need to fix something in a big way, Git provides a number of administrative commands to help you out.

git gc

The git gc command runs “garbage collection” on your repository, removing unnecessary files in your database and packing up the remaining files into a more efficient format.

This command normally runs in the background for you, though you can manually run it if you wish. We go over some examples of this in Maintenance.

git fsck

The git fsck command is used to check the internal database for problems or inconsistencies.

We only quickly use this once in Data Recovery to search for dangling objects.

git reflog

The git reflog command goes through a log of where all the heads of your branches have been as you work to find commits you may have lost through rewriting histories.

We cover this command mainly in RefLog Shortnames, where we show normal usage to and how to use git log -g to view the same information with git log output.

We also go through a practical example of recovering such a lost branch in Data Recovery.

git filter-branch

The git filter-branch command is used to rewrite loads of commits according to certain patterns, like removing a file everywhere or filtering the entire repository down to a single subdirectory for extracting a project.

In Removing a File from Every Commit we explain the command and explore several different options such as --commit-filter, --subdirectory-filter and --tree-filter.

In Git-p4 and TFS we use it to fix up imported external repositories.

scroll-to-top