LoginSignup
3
2

More than 5 years have passed since last update.

大事なファイルを消したいときのgit filter-branch

Posted at

大事なファイルをリモートリポジトリにpushしてしまっていた時に使えるgit filter-branch

git filter-branch -f --index-filter 'git rm -rf --ignore-unmatch [ファイル名]' HEAD
で消したいファイル名を指定し該当の削除して

git gc --aggressive --prune=now
で過去のcommitした上記ファイルを消して最適化して

git push -f
-fオプションをつけて強制的にpush。 (強制的に上書きされるので注意が必要です)

3
2
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
3
2