CS FundamentalsHardProduct-company MCQ pattern

A file secrets.env was committed last month. Today you add secrets.env to .gitignore and commit. Why does git status still show changes to it, and what fixes that?

  1. A. Because .gitignore needs a restart of Git; running git gc fixes it
  2. B. Because .gitignore must be committed on main first; merging it fixes it
  3. C. Because the pattern is case-sensitive; writing SECRETS.ENV fixes it
  4. D. Because .gitignore only affects untracked files; git rm --cached secrets.env stops tracking it while keeping it on disk

Correct answer: D. Because .gitignore only affects untracked files; git rm --cached secrets.env stops tracking it while keeping it on disk

.gitignore never applies to files already in the index. git rm --cached removes the file from tracking (it stays in old history, so a leaked secret must still be rotated).

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic