Cleaning the Git repository

How to clean the git

  • to see what’s dangling
    git fsck
    git reflog
  • to clean
    git reflog expire --expire=now --all
    git gc --prune=now
  • examples
    git reflog expire --expire=now --all
    git reflog 
    # reflog should be cleaned
    [email protected]:~/stl/_devops/chef-sl_policy_import(master)$ git gc --prune=now
    Counting objects: 409, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (304/304), done.
    Writing objects: 100% (409/409), done.
    Total 409 (delta 215), reused 126 (delta 56)
    [email protected]:~/stl/_devops/chef-sl_policy_import(master)$ git fsck
    Checking object directories: 100% (256/256), done.
    Checking objects: 100% (409/409), done.
Related Post