Skip to content

Instantly share code, notes, and snippets.

@bathivinod
Created June 13, 2025 18:27
Show Gist options
  • Select an option

  • Save bathivinod/7a681b970f9567440b31b1afc4336d1a to your computer and use it in GitHub Desktop.

Select an option

Save bathivinod/7a681b970f9567440b31b1afc4336d1a to your computer and use it in GitHub Desktop.
How to install and use git-filter-repo on Windows

🧹 Removing Large Files from Git History with git-filter-repo

πŸ“‹ Overview

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:

  • πŸ“¦ .exe files
  • πŸ“₯ .zip archives
  • πŸ”§ Terraform artifacts
  • πŸ“ Other large binary files

❓ Why Use git-filter-repo?

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.

πŸš€ Installation Guide

πŸ“‹ Prerequisites

  • βš™οΈ Git installed on Windows
  • 🐍 Python installed and added to system PATH

πŸ“₯ Installation Steps

  1. πŸ“₯ 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
  2. πŸ“¦ Install the Script

    • Move the downloaded script to your Git installation's core directory:
      C:\Program Files\Git\mingw64\libexec\git-core\
      
  3. βœ… Verify Python Installation

    • Open a terminal and run:
      python --version

πŸ’» Usage

πŸ—‘οΈ Removing .exe Files from History

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

⚠️ Important Notes

  • πŸ”’ Always create a backup of your repository before using git-filter-repo
  • ⚑ The --force flag 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

πŸ“š Additional Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment