2. Git Basics
7. Git Tools
10. Git Internals
A3.11 Appendix C: Git Commands - 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 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 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 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 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