gitbitbucketdelete-file

Remove files completely from a Git repository along with its history


I have uploaded a font file that I don't have the rights to distribute to GitHub several updates ago.

I have a relatively inactive repository and I have the ability to notify all of my members if necessary. I've tried several of the solutions. I need to delete a file in my directory called Resources\Video\%font%.ttf where %font% is the name of the plain, italicized and bold versions of the font. What commands do I use?


Solution

  • In that case, you could to use the Git Filter Branch command with the --tree-filter option.

    The syntax is git filter-branch --tree-filter <command> ...

    git filter-branch --tree-filter 'rm -f Resources\Video\%font%.ttf' -- --all
    

    Note that git filter-branch --index-filter is much faster than --tree-filter

    git filter-branch --index-filter 'rm -f Resources\Video\%font%.ttf' -- --all
    

    In Windows, I had to use / instead of \.

    Explanation about the command:

    < command > Specify any shell command.

    --tree-filter: Git will check each commit out into working directory. Run your command, and re-commit.

    --index-filter: Git updates git history and not the working directory.

    --all: Filter all commits in all branches.

    Note: Kindly check the path for your file as I'm not sure for the file path