要らないデータの大きさを簡単に確認する方法
git clone https://github.com/daijinload/test.git
cd test
wget https://confluence.atlassian.com/bitbucket/files/321848291/321979854/1/1360604134990/git_find_big.sh
chmod 755 git_find_big.sh
./git_find_big.sh
中に入ってダウンロードしたシェルスクリプトを実行するだけ。
bfgを使ってファイルを削除する方法
※注)必ずバックアップを取ってから実行してください。
wget https://repo1.maven.org/maven2/com/madgag/bfg/1.13.0/bfg-1.13.0.jar
git clone --mirror https://github.com/daijinload/test.git
du -hs test.git/objects
java -jar bfg-1.13.0.jar -D 'bigfile1' test.git
java -jar bfg-1.13.0.jar -D 'bigfile2' test.git
cd test.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
以上で、Gitのリポジトリが軽くなります。
先頭コミットのハッシュ値が変わってなかったですが、リリースしたときのハッシュ値を保存しているような現場では、調べてから実行したほうが良いと思います。
また、念のため作業者全員のローカルのGitをcloneしなおしたほうが良いと思います。
とりあえず、リポジトリを軽くしたい人は、ぜひ!!
参考URL
// git_find_big.shの説明
https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html
// bfg.jar
https://rtyley.github.io/bfg-repo-cleaner/