To remove the tracked and old committed file from git you can use the below command. Here in my case, I want to untrack and remove all the file from dist
directory.
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch dist' --tag-name-filter cat -- --all
Then, you need to add it into your .gitignore
so it won't be tracked further.