素肌にサスペンダー

個人的な備忘と日記

GitHubに100Mb以上のサイズのファイルをpushしようとして拒否された時の対応

100Mb以上のサイズのファイルをpushしようとして拒否された。 GitHub desktopというクライアントツールを使っていて、以下のメッセージが出た。

The push operation includes a file which exceeds GitHub's file size restriction of 100MB. Please remove the file from history and try again.

以下のコマンドで、そのファイルが追加された事を抹消出来た。

git filter-branch -f --tree-filter 'rm -f {path to file}' HEAD

※filter-branchの後の-fは、backupファイルを上書きするためのオプション。 これがないと、複数消したい場合、以下のエラーが出た。

Cannot create a new backup. A previous backup already exists in refs/original/ Force overwriting the backup with -f