I have read about how to remove files that are in the ignore file from a repository using git commands here: Remove directory from remote repository after adding them to .gitignore.
I am using Visual studio 2019 with a repository in Azure DevOps. I have used these steps:
- From the Git Explorer Menu, "Open in Command Prompt"
git rm -r --cached .This tells git to stop tracking everything and now I have all my files showing as deleted in "Staged Changes" and a smaller number of files showing as added in "Changes". This looks good. I assume ignored files are not added back again, so when I commit those additions all the files that should have been ignored in the first place will be deleted on the server.- Stage. Now it looks like there's a problem. The added files are showing as modified.
- Push to see what they look like when I view the changes in the browser: "Only showing the first 999 changes. Click here to load more". And every file I can see has a warning: "The file differs only in whitespace"
I'm guessing it's about line endings but it makes it nearly impossible to review the changes. Is there a way to stop the whitespace changes occurring when I use this process? Or to reverse the whitespace changes? Or tell git to only check in the deletes?
TLDR Answer (from VonC):
git rm -r --cached .
git config --global core.autocrlf false
git add --renormalize .
git add .
git commit