Skip to content

Instantly share code, notes, and snippets.

@skanehira
Last active July 6, 2020 07:55
Show Gist options
  • Save skanehira/1a564cc03408411edfbf71c8a138b436 to your computer and use it in GitHub Desktop.
Save skanehira/1a564cc03408411edfbf71c8a138b436 to your computer and use it in GitHub Desktop.

How to maintain a git repository

Check size of a repository.

$ du -hs .git/objects

If repository has more than 50 packfile or 7000 objets, you can run gc.

$ git gc --auto

Also you can use git_find_big.sh

$ curl -LO https://confluence.atlassian.com/bitbucket/files/321848291/321979854/2/1587501654761/git_find_big.sh
$ bash git_find_big.sh

You can delete big file from git log with below command.

$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch ${filename}' -- --all

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment