2 changeGitHistroy
erik edited this page 2024-04-25 14:53:22 +02:00

How to change the commit History in a git repo

This is usefull if you want to permanently delete something form a git repo (attackers can clone the repo and revert commits which deleted files). This Methode rewirtes the git History. Only use if necessary.

Step1: clone repo again (you might break stuff)

Step2: install git-filter-repo

sudo pacman -S git-filter-repo

Step3: use git-filter-repo to delete files

git filter-repo --invert-paths --path <path to the file or directory>

Step4: add origin again

git remote add origin <link to repo>

Step5: force push

git push origin --force --all