Git
Cleanup Commands
Keep your repository healthy and performant. Learn to prune old branches, clean up untracked files, and optimize your repository with garbage collection and maintenance commands.
8 commands
Pro Tips
Use 'git clean -n' (dry run) before 'git clean -f' to preview what will be deleted.
Run 'git remote prune origin' to remove local references to deleted remote branches.
Use 'git branch --merged | grep -v main | xargs git branch -d' to safely delete merged branches.
Common Mistakes
'git clean -f' permanently deletes untracked files. Always use -n (dry run) first to verify.
Running 'git gc' aggressively can remove unreferenced objects you might need for recovery.