How to remove permanently an object in GIT

L'Antre du Tryphon

schedule
2017-04-14 | 23:41h
update
2021-04-11 | 00:46h
person
www.ctheroux.com
domain
www.ctheroux.com

How to remove permanently an object in GIT

To remove permanantly an object in a remote GIT repository, simply perform these steps. Prior executing them, go to the GIT project folder. This is the one having the .git folder.

git filter-branch -f --index-filter "git rm -rf --cached \ --ignore-unmatch OBJECT-TO-DELETE" -- --all rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --prune=now git gc --aggressive --prune=now git push --all --force

Replace OBJECT-TO-DELETE with the object to delete. For example, if you want to delete a complete folder called distributions located in the tools folder, replace OBJECT-TO-DELETE by tools/distributions

The local copy of the modified repository cloned else where will have to be re-cloned.

*** Keep a backup your repository before performing these operations ***.

Advertisement

Imprint
Responsible for the content:
www.ctheroux.com
Privacy & Terms of Use:
www.ctheroux.com
Mobile website via:
WordPress AMP Plugin
Last AMPHTML update:
06.04.2024 - 03:23:17
Privacy-Data & cookie usage: