This guide provides instructions for installing and using git-filter-repo on Windows to remove large or unwanted files from your Git repository history. This is particularly useful for removing files like:
- π¦
.exefiles - π₯
.ziparchives - π§ Terraform artifacts
- π Other large binary files
GitHub has a file size limit of 100 MB per file. Even if you delete a large file from your current repository, it remains in your Git history. This can cause issues when pushing to GitHub. git-filter-repo is the recommended tool for safely rewriting Git history to remove these files.
- βοΈ Git installed on Windows
- π Python installed and added to system PATH
-
π₯ Download the Script
- Visit the official repository: git-filter-repo
- Download the Python script by right-clicking this link and selecting "Save As"
- Save the file as
git-filter-repo.py
-
π¦ Install the Script
- Move the downloaded script to your Git installation's core directory:
C:\Program Files\Git\mingw64\libexec\git-core\
- Move the downloaded script to your Git installation's core directory:
-
β Verify Python Installation
- Open a terminal and run:
python --version
- Open a terminal and run:
To remove all .exe files from your Git history:
python "C:\Program Files\Git\mingw64\libexec\git-core\git_filter_repo.py" --path-glob '*.exe' --invert-paths --force
git push origin master --force- π Always create a backup of your repository before using
git-filter-repo - β‘ The
--forceflag is required as this operation rewrites history - π₯ All team members will need to re-clone the repository after these changes
- π’ Make sure to communicate these changes to your team before proceeding