Skip to main content

Posts

Showing posts with the label git

How to Remove a Directory from All Git Commits and Branches

If you work in consultancy, you might encounter a situation where you need to hand over a project repository to a competitor. However, the repository contains some proprietary code that shouldn't have been included in the first place. Is it possible to completely remove a directory from the git history? Let's explore how we can achieve this. Prerequisites The first and most important note is that I was unable to achieve this on Windows . Instead, I had to create a virtual machine with Linux (Ubuntu 22.04) . Git and python3 were preinstalled. Unfortunately, git alone won't suffice. You need to install 'git-filter-repo' , a handy tool for rewriting git history. You can get it from GitHub ( https://github.com/newren/git-filter-repo ) or use pip to install it. I went with pip for simplicity. First, install pip : apt install python3-pip Then install git-filter-repo : python3 -m pip install --user git-filter-repo Check if the installation was completed succe

About author

My photo
Jan Binder
Experienced Salesforce Technical Architect and Team Lead with a proven track record of delivering successful enterprise projects for major global companies across diverse industries, including automotive, oil & gas, and construction.