LoginSignup
1
0

More than 3 years have passed since last update.

BFG Repo-Cleanerを使ってGitリポジトリを軽くした件

Posted at

要らないデータの大きさを簡単に確認する方法


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/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0