For Google Searchists:
I had the same problem. After trying a lot of different stuff, I ended up just deleting the git repository and recreating it.
Remove the .git folder which stores the commits etc
rm -rf .git
create an empty repository
git init
adjust your .gitignore to ignore the files you dont want or remove the files.
Stage everything
git add .
Check if your files are no longer included
git status
create your new, first commit
git commit -m "Initial commit"
because we removed the repository earlier, we lost the connection to our remote (github, gitlab, ...) repository. re-add your remote repository, e.g.
git remote add origin [email protected]:my_username/my_repo
force-push everything with recreating the branch. Adjust the branch name to be your actual branch name, otherwise you just create a new branch and the files you wanted to remove are still on your old branch.
git push --set-upstream origin master -f
.git
directory and rungit init
+git remote add
then commit. – Heehaw