LoginSignup
50
54

More than 5 years have passed since last update.

Gitで重いリポジトリをcloneするとき

Posted at

WordPressの中規模サイトをGitで管理していて、
ファイル容量を圧迫していたので一旦削除したのですが、
今回また修正の必要が出てきてSourceTreeでクローンしようとしたら、

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree fetch origin 
remote: warning: suboptimal pack - out of memory        
error: pack-objects died of signal 9
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header
Completed with errors, see above

と行き詰まってしまいました。

こんなときは多分SourceTreeではどうにもならず、

git clone --depth 1 http://example.com/fuga.git
git fetch --depth 10
git fetch --depth 100 # 値は調整しつつ
git fetch --unshallow # 最後に全部落とす このオプションは最新のgitでないとない

とやっていくことで完全に落とせました。
今回はdepthを100から50〜100刻みで調整して、500ぐらいまで上げたら
unshallowが成功しました。
クローンしたGitリポジトリの容量を調べたら約10GBありました。
重いー。

こちらの記事を元に補足しました。
gitで重いリポジトリをcloneするとき - webネタ

50
54
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
50
54