This repository was archived by the owner on Mar 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup-git.ps1
More file actions
49 lines (40 loc) · 1.76 KB
/
cleanup-git.ps1
File metadata and controls
49 lines (40 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Git Cleanup Script for api-server
# This script cleans up the git repository to speed up operations
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "Git Cleanup - api-server" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
# Check current state
Write-Host "Current git repository state:" -ForegroundColor Yellow
git count-objects -vH
Write-Host ""
# Step 1: Remove garbage objects
Write-Host "Step 1: Removing garbage objects..." -ForegroundColor Yellow
git gc --prune=now
Write-Host " [OK] Garbage collection complete" -ForegroundColor Green
Write-Host ""
# Step 2: Prune unreachable objects
Write-Host "Step 2: Pruning unreachable objects..." -ForegroundColor Yellow
git prune --expire=now
Write-Host " [OK] Pruning complete" -ForegroundColor Green
Write-Host ""
# Step 3: Repack objects (compress loose objects into packs)
Write-Host "Step 3: Repacking objects..." -ForegroundColor Yellow
git repack -ad
Write-Host " [OK] Repacking complete" -ForegroundColor Green
Write-Host ""
# Step 4: Final cleanup
Write-Host "Step 4: Final garbage collection..." -ForegroundColor Yellow
git gc --aggressive --prune=now
Write-Host " [OK] Final cleanup complete" -ForegroundColor Green
Write-Host ""
# Show new state
Write-Host "New git repository state:" -ForegroundColor Yellow
git count-objects -vH
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "Cleanup Complete!" -ForegroundColor Green
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Your git operations should be much faster now!" -ForegroundColor Green
Write-Host ""