To delete a large file from a Git repository and completely remove it from the history:
git rm --cached path/to/file
This will remove the file from the current commit but keep it in the repository history.
git commit -m "Removed large file from repository"
Now, to completely remove the file from the repository history, you need to use Git's filter-branch command. This command rewrites the repository history by applying a filter to each commit. To remove the file from all commits, run the following command:
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch path/to/file" \
--prune-empty --tag-name-filter cat -- --all
This command will rewrite the entire history of the repository, so it may take some time to complete.
Finally, force push the changes to the remote repository to update the repository history:
git push --force
Anyone who has cloned the repository before you force push the changes will need to manually update their repository to reflect the new history.
WARNING: git-filter-branch has a glut of gotchas generating mangled history
So the other option is:git filter-repo --invert-paths --path path/to/file