When I forget to write it in .gitignore and commit it, “Adding to .gitignore is all right…” Do you misunderstand that? Like me.. sweat
The files already managed by Git will not be removed simply by adding it to .gitignore later, so I will write a countermeasure for such a case.
If you want to keep the files managed by Git and exclude them
$ git rm --cached [filenames to exclude]
After that, be sure to add the file you want to exclude to
Be sure to add
If not attached, the files will be deleted.
If you want to delete each file
$ git rm [filename you want to delete]
If you want to delete each directory
$ git rm -r [directory to delete]
When I started using Git, I forgot a few times and committed it, and I checked it each time, so I will leave it as a memorandum.
I hope it will be useful for those who have the same circumstances.