Created
August 22, 2016 23:50
-
-
Save cakriwut/ac240087689e4831edd90ef28a893bb2 to your computer and use it in GitHub Desktop.
Remove file/folder from GIT repo permanently
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM Remove folder Sample/packages from GIT repository | |
git --filter-branch --index-filter "git rm --cached --ignore-unmatch -rf Sample/package" --prune-empty --tag-name-filter cat -- --all | |
REM Remove file Sample/packages/filetoremove.txt from GIT repository | |
git --filter-branch --index-filter "git rm --cached --ignore-unmatch Sample/package/filetoremove.txt" --prune-empty --tag-name-filter cat -- --all | |
REM push the result to origin | |
git push origin --force --all | |
git push origin --force --tags | |
REM cleanup - if everything OK | |
git for-each-ref --format="delete %(refname)" refs/original | git update-ref --stdin | |
git reflog expire --expire=now --all | |
git gc --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment