debug.log is still reported as modified because it was already tracked. Which command stops tracking it but keeps the file on disk?
$ echo "debug.log" >> .gitignore $ git status --short M debug.log ?? .gitignore
git rm --cached debug.loggit rm debug.loggit update-index debug.loggit restore debug.log
Ignore rules only affect untracked files.
Play Git ▸
git rm --cached removes the file from the index only, so it becomes untracked and the ignore rule applies.