Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.52 KB

File metadata and controls

57 lines (43 loc) · 1.52 KB

Git Cleanup

Repository maintenance and recovery. These commands help you free up space, remove untracked garbage, or recover lost commits.

Clean untracked files

git clean removes untracked files from your working directory. It's often used with -fdx to reset the repository to a pristine state (removing ignored build artifacts too). #nuke-untracked #purge #wipe #empty

git clean $clean_flags

Garbage Collection

Git automatically runs garbage collection occasionally, but you can force it to optimize your repository immediately. #optimize #compress #maintenance

git gc --prune=now

Check repository integrity

git fsck

Reflog (Recover lost commits)

The reflog records every time your branch tips are updated (e.g., switching branches, rebasing, resetting). If you accidentally do a hard reset, you can find the lost commit hash here. #recover #lost-commits #history #rescue

git reflog

Prune unreachable objects

git prune