CodeBlanks Logo Icon CodeBlanks

Summary - Performance

Combine maintenance commands to keep the repository healthy.

Combine Git repository maintenance

You can combine maintenance, cleanup, and verification tasks to keep a Git repository healthy. git gc organizes objects, git prune removes unreachable objects, and git fsck checks integrity.

git gc
git prune --dry-run
git fsck --full

Previewing and verifying before cleanup helps reduce the risk of accidental data loss.

Practice Create a maintenance and verification sequence

First run Git garbage collection. Then preview the removal of unreachable objects and finally perform a full integrity check. Print a completion message at the end.

Starter code

terminal
# Depo nesnelerini düzenle
# Erişilemeyen nesneleri önizle
# Depo bütünlüğünü doğrula
# Tamamlanma mesajını yazdır

Sample solution

terminal
git gc
git prune --dry-run
git fsck --full
echo 'Bakım ve doğrulama tamamlandı'

Expected output

Bakım ve doğrulama tamamlandı

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 You want to organize objects, preview unreachable objects before deletion, and verify integrity during repository maintenance. Which command sequence meets these goals?

  • git gc, git prune --dry-run, git fsck --full Correct answer
  • git branch, git switch, git merge
  • git add, git commit, git push
  • git status, git log, git diff

Explanation: <code>git gc</code> performs maintenance, <code>git prune --dry-run</code> previews objects to be removed, and <code>git fsck --full</code> checks integrity.

2 Complete the verification command in the maintenance sequence

Question
git gc
git prune --dry-run
git ____ --full
Answer
git gc
git prune --dry-run
git fsck --full

Explanation: <code>git fsck --full</code> performs a comprehensive integrity check of repository objects during maintenance.

3 Repository maintenance commands

Term Meaning
git gc Organizes and packs objects
git prune Removes unreachable objects
git fsck Checks object integrity
Maintenance Regular repository maintenance process

All lessons in Expert